WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have three categories (news, pics, vids), but I have all of them showing up on my front page. I would just like the front page to have the news category (and possibly uncategorized category) to show. What is the best way to do this? Plugin? Or a piece of code on the front page?

share|improve this question
up vote 5 down vote accepted

Try adding this code to functions.php file:

add_action('pre_get_posts', 'ad_filter_categories');
function ad_filter_categories($query) {
    if ($query->is_main_query() && is_home()) {
        $query->set('category_name','news, uncategorized');

category_name is the slug or the nicename of the category. Add a comma separated list of the categories you wish to include.

share|improve this answer
Thanks, that worked perfectly. I appreciate your help! – EGHDK Nov 25 '12 at 21:43
i add this code to my theme > functions.php file but no change detcted – Navid_pdp11 May 28 at 13:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.