How to display posts from a certain category on a page
-
Hello
I have setup a few pages on my site and also setup separate page templates for each page. From there I was going to add in code to display posts on each page depending on the category id number.My question is what would be the appropriate code for the loop to display the posts from only a certain category id. I have been reading about it and came up with this:
<?php $lastposts = get_posts('numberposts=10&category=6'); foreach($lastposts as $post) : setup_postdata($post); ?>
Though I am not sure if that is correct. It does work but only the first two posts appear correctly, the next two go down to the bottom of the page and past the sidebar. I also set up a custom field and a css style for that fields data. It only appears correctly (the style) on the first post.
You can see the results on my site (which I am just starting to design)
My SiteI appreciate any help anyone can offer. I am just starting on wordpress and have been working on this for about ten hours today. I am at the point now where I have to walk away because it is all getting confusing 🙂 It is probably an easy solution that I am not seeing.
THANKS
- The topic ‘How to display posts from a certain category on a page’ is closed to new replies.