Posts Tagged ‘Hacking’
Retrieving Posts from a Particular Category
Written by Jai on December 2, 2007 – 5:38 pm - 4,121 views14 Comments

Many people have asked me how to show posts on their homepage only from a particular category or categories. So here is a simple and quick solution for doing this.
Getting Posts from a Single Category
Go and open your index.php file from your theme folder. Now search for this string :-
<?php if (have_posts()) : ?>
Now just below this line, add the following piece of code:-
<?php
if (is_home()) {
query_posts('category_name=General');
}
?>
The above code will display posts only from the category called “General” on your home page. You can change this to any of your category names. Read more
If you enjoyed this post, make sure you subscribe to my RSS feed!








