0
votes

I am fairly new to wordpress and trying to use the Pinboard theme. I have created different pages and I want to show posts belonging to one category on each page. Although, it seems like a pretty common question I am still not able to understand how to do it exactly.

I assume that I have to write this code somewhere:-

query_posts( array ( 'category_name' => 'my-category-slug', 'posts_per_page' => -1 ) );

But, I don't know which file/location should I put it in, and if I need any plugins for this to work.

3

3 Answers

0
votes

I think you hava a lot of options in this excellent post: How to Show WordPress Posts from a Single Category Only

0
votes

You can either create a page named 'category-[category-slug].-php' and use the query
query_posts('posts_per_page=-1');
or
create a file named catagory.php and use the query
query_posts( array('category_name'=>get_query_var('cat'),'posts_per_page'=>-1 ) );

The first will give you the results for only the category with that slug while the second will give you results for any category based on slug

I hope this helps.

0
votes

It's a little easier for those of us who are less tech-savvy. Just go to the appearance>menus tab on the wordpress dashboard.

Then simply, instead of adding a page to your menu structure, add a category from the list of post categories to your menu.

Done.