Showing Posts on Page based on Categories?
-
Using Hemingway theme, I’m looking to created a page template that show blog posts tagged with a specific category. I’ve already created my template, but currently it’s only pulling from one category, because I’ve set it using:
`query_posts(‘category_name=sports&posts_per_page=-1′);’
However, I would need to create a new page template if I created a new page for a different category. So in order to reuse the same page template, I’d like to have code that checks to see the page and category match and show only posts with the category sports and so forth attached to it.
For Example:
I have 3 PAGES (Sports, Cars, and Animals), and I have 3 CATEGORIES (Sports, Cars, and Animals). I also have 10 posts for SPORTS, 10 for CARS, and 5 for ANIMALS. When you click on SPORTS on the main navigation on the front page, it should take you to the SPORTS page and show all 10 posts about SPORTS, and so on.
I also found a post here regarding the same thing, I think… but not sure where to place the code. There’s a code example by user: funkboybilly. Here’s a link to that post: Creating Page Based on Category
Any help would be greatly appreciated. Thank you guys!
- The topic ‘Showing Posts on Page based on Categories?’ is closed to new replies.