Support » Themes and Templates » exclude category from the home page posts

  • Resolved ottanio


    i have a template download from
    this part of the index page exclude the category (‘illustration’) from the hom page posts.
    <?php get_header(); ?>
    <div class=”home_big_post_cont”>
    $exclude_arr = array();
    $category_ID = get_category_id(‘illustration’);
    $args = array(
    ‘post_type’ => ‘post’,
    ‘cat’ => ‘-‘ . $category_ID,
    ‘posts_per_page’ => 3
    $x = 0;
    while (have_posts()) : the_post(); ?>

    How can I exclude also other categories? ex. (‘news’)

Viewing 7 replies - 1 through 7 (of 7 total)
  • There is a plugin that will do it. I think it is called ultimate category excluder or something like that. search for it in you install plugin area. I would look it up for you but I’m on my cell phone so hard to do.

    i will try thanks



    Forum Moderator

    without plugin:

    $exclude_arr = array();
    $category_ID_1 = get_category_id('illustration');
    $category_ID_2 = get_category_id('news');
    $args = array(
    'post_type' => 'post',
    'category__not_in' => array( $category_ID_1, $category_ID_2 ),
    'posts_per_page' => 3

    or you can simply find the id’s of both categories from the wordpress dashboard and exclude them like:
    'cat' => '-1,-2';
    more @ #Exclude_Categories_From_Your_Home_Page


    I agree coding it out is lighter but if you add more categories later on you don’t have to keep fiddling with the code when using the plugin. With the plugin you can check box the category out when adding a new category.

    i installed the plugin, works… Great!!!!
    the code doesn’t work (alchymyth), i see all categories, i don’t know why.
    Thanks for the help
    Little question:
    i have in the home: last projects (6posts), last news (three posts), random projects (three posts).
    is it possible exlude the categories (illustrator,news) from the first 6 post in home, but not exclude these from the random posts?
    Exclude for a part of the home….
    maybe is possible change the code of the plugin.
    thanks a lot to all.

    i made a mistake the code (alchymyth) works
    thanks to all

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘exclude category from the home page posts’ is closed to new replies.