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! |
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 ... ?> } ?> |
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? |
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/
|
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. |
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:
PHP Code:
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. |
All times are GMT -6. The time now is 02:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.