Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Plugins & Atahualpa »

Posts of Category "Bulletin" on home page?


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Aug 4, 2009, 04:31 PM
RAMilewski's Avatar
RAMilewski
 
16 posts · Aug 2009
San Jose, California
Posts of Category "Bulletin" on home page?

I'm running Atahualpa 3.4.2 on Wordpress 2.8.3. ...and I'm a Wordpress NOOB.

Mostly, I'm using Wordpress as a CMS for a site with lots of static pages. But I would like to have the most recent post (preferably the most recent post in the "bulletin" category) appear above the content of the page "home".

Settings>Reading>Front Page Displays is set to "a static page".

Can I add something to Altahualpa Options in the "content ABOVE the LOOP" section to display the latest post in the "bulletin" category?

or....

Should I change Settings>Reading>Front Page Displays to "your latest posts" with a loop size of 1, and try to add something to Altahualpa Options in the "content BELOW the LOOP" section to display the page "home". ...if so what goes there?

Thanks!
  #2  
Old Aug 8, 2009, 06:00 AM
Flynn's Avatar
Flynn
 
3,745 posts · Oct 2008
Munich, Germany
See http://codex.wordpress.org/Template_Tags/query_posts

and wrap your code into

<?php if ( is_front_page() ) {
...query_posts code here, without opening and closing php tags <?php ... ?>
} ?>
  #3  
Old Aug 14, 2009, 02:05 PM
RAMilewski's Avatar
RAMilewski
 
16 posts · Aug 2009
San Jose, California
Thanks, that gets me closer, but I'm unclear where to place that code.

The code snippet I'm using is:

<?php if ( is_front_page() ) { query_posts('showposts=1&cat=6'); } ?>

If I put that in the "Content ABOVE the LOOP" section, then the desired post displays correctly, but front page never displays.

What did I misunderstand?
  #4  
Old Aug 16, 2009, 04:10 AM
Flynn's Avatar
Flynn
 
3,745 posts · Oct 2008
Munich, Germany
You're right, the query_posts stomps the page content. I suggest the plugin Page2Cat which can combine static page content and posts http://wordpress.org/extend/plugins/page2cat/
  #5  
Old Aug 16, 2009, 12:28 PM
RAMilewski's Avatar
RAMilewski
 
16 posts · Aug 2009
San Jose, California
Thanks Flynn!

I had looked at that briefly and gave it a pass because it was listed as being compatible only up to Wordpress 2.5. ...but I'll give it a try and report the results back here.
  #6  
Old Aug 16, 2009, 05:21 PM
RAMilewski's Avatar
RAMilewski
 
16 posts · Aug 2009
San Jose, California
Hmmm... OK so I think I can make this work, but there are some problems with page2cat (or Category Pages as it calls itself in the dashboard):

1 - It appears to be unsupported, so I doubt we ever see a real 2.8 version. Neither the support forum link nor the author link appear to work. That said, I haven't seen any bad behavior in WP 2.8.4 with Atahualpa 3.4.2.

2 - The short-tag functionality, which is the part I need, only puts up a link-list of the selected posts.

3 - It puts the posts after the page title and before the page content. I can finesse this problem by checking the "Do Not Dispaly" box in Atahualpa Page Options and putting my front page title in the body in a <h1 class="pseudo-headline"> tag, and then defining the style for that in the Add HTML/CSS Inserts section of Atahualpa theme options. I had thought I could just use a <h1 class="post-headline"> tag, but that doesn't work for reasons I don't understand.


Solving problem #2 was a bit more involved. Let me preface this by saying I'm not a php or Wordpress expert, and I've never written a plug-in for Wordpress. But... I cranked up my courage and added the following lines to page2cat.php starting about line #631:

PHP Code:
// Hack by RAMilewski to filter the content of a page, check for [bulletin=xx] tag and replace it with the posts in the requested category  

// NOTE: uses the same count and category settings as the [catlist=xx] tag. This is bad.
function page2cat_bulletin($content){
global 
$post;
    if ( 
stristr$content'[bulletin' )) {
        
$search "@(?:<p>)*\s*\[bulletin\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
        if    (
preg_match_all($search$content$matches)) {
            if (
is_array($matches)) {
                
$output "<div class='p2c_bulletin'>";
                
$limit get_option('p2c_catlist_limit');
                foreach (
$matches[1] as $key =>$v0) {
                    
$catposts get_posts('category='.$v0."&numberposts=".$limit);
                        foreach(
$catposts as $single):
                        
$output .="<h2>".$single->post_title."</h2>";
                        
$output .="<p>".$single->post_content."</p>";
                        endforeach;
                        
$output .= "</div>";
                    
$search $matches[0][$key];
                    
$replace$output;
                    
$contentstr_replace ($search$replacecontent);                
                }
            }
        }
    }
return 
$content;

I also added this line at the end of the file:


PHP Code:
add_filter('the_content','page2cat_bulletin'); 

These changes appear to add a new short tag of the form [bulletin=xxx] that works like the page2cat [catlist=xxx] tag except that it inserts both the title and content of the post into the page.

You can style the insert by adding styles for the class p2c_bulletin to the Add HTML/CSS Inserts section of Atahualpa theme options.

If anyone out there decides to duplicate this, please note that it was implemented by a bear of very little brain, and that it has been only summarily tested. I don't know the plug-in development process well enough to work through the issues of giving the [bulletin=xxx] short tag it's own category and limit controls in the Category Pages control panel, at least not within the time I have allotted for this project, so this whole thing should be considered just an unsupported hack.

The new function is a slight modification of the page2cat_content_catlist() function which comes just before it in the hacked file. Note that I believe there is an error in that function. The line:

$output .= "</ul>";

near the end of the function should, I believe, be moved to just after the endforeach; line so that the closing tag is included in $content by the str_replace() operation.

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static text/banner image before posts in "posts page" verbalicious Page & Category Menu Bars 14 Nov 12, 2010 05:27 AM
Default "home" in page menu, how do I attach a post or page to it? LoneGunman Page & Category Menu Bars 3 Aug 1, 2010 06:55 PM
Can I get rid of the word "Home" below menu bar on the home page? nasu Page & Category Menu Bars 1 Jun 30, 2009 02:36 PM
Problem implementing "How to show single post special category on static home page??" mkny13 Post-Kicker, -Byline & -Footer 6 May 5, 2009 05:21 AM
Flexx theme - How to change my "List Category or Archives" to "List Titles ONLY" ?? idaks01 Post-Kicker, -Byline & -Footer 0 Mar 28, 2009 05:22 PM


All times are GMT -6. The time now is 03:40 AM.


Powered by vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.