Forums

How can I exclude a category from this code... (2 posts)

  1. andymacdonalduk
    Member
    Posted 9 months ago #

    Hey Guys,

    I am trying to exclude some categories from a post query on my home page, the usual ('exclude' => '-6,-12,-15') isn't working... but Im not very good at coding.

    Here is my query code:

    <?php
                            $my_query = new WP_Query( array( 'post_type' => 'portfolio', 'showposts' => '3' ) );
                            while ($my_query->have_posts()) : $my_query->the_post();
    
                            $custom = get_post_custom($post->ID);
                        ?>

    I have been trying different variations of the following exclude code, but it's not working. Please help???

    ' 'exclude' => '-6,-12,-15' '

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 9 months ago #

    http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

    'cat' => array( -6, -12, -15),

    would work I believe, or also look at category__not_in

Reply

You must log in to post.

About this Topic