I'm trying to figure out how on the homepage I can only display the posts from just one category instead of several categories. I figured out how to display content from a page, but I want to display posts. Just from one category.
I'm trying to figure out how on the homepage I can only display the posts from just one category instead of several categories. I figured out how to display content from a page, but I want to display posts. Just from one category.
Use the template tag, query_posts(), and the cat= parameter.
Resources:
The Loop
Template Hierarchy
Stepping Into Templates
I tried that in a home.php template and it just came up with a Parse Error on line 44. Did I place the content correctly?
[code moderated]
See if this works:
http://pastebin.ca/1222663
Still get this:
Parse error: parse error, unexpected T_ENDWHILE in /home/content/w/i/l/willdurst/html/lobsterssundaybrunch/wp-content/themes/lsb/home.php on line 44
Oops, missed the extra endif and endwhile
Yep, that did the trick. Thanks so much for your help.
Hi MichaelH, could you post that code again? I believe your post on pastebin has expired...!
yes, please, someone re-post that code.
I used this <?php query_posts('cat=1&showposts='.get_option('posts_per_page')); ?> before the loop, you need to change cat=1 to the id of your category.
I would like to achieve something else, show posts only from one category but the latest post from that category to be styled different.`
What I have now does this thing, styles different the latest post only if the post is from that category, if the latest post is from another category I see regular posts.
Any ideas?
Thanks! That's exactly what I was looking for.
This topic has been closed to new replies.