WordPress.org

Ready to get started?Download WordPress

Forums

query_posts 'cat' excluding everything (3 posts)

  1. nathanael.montgomery
    Member
    Posted 2 years ago #

    I'm attempting to include only posts from category 13 & 14. I've tried the following method as well as excluding posts from all other categories and using category__and => array (13, 14). With both methods, I end up with nothing showing.

    query_posts (array( 'post_type' => 'theme_portfolio', 'showposts' => $portfolio_items_num, 'paged'=>$page, 'order'=> 'ASC', 'cat'=>13, 14));

    Any ideas would be greatly appreciated!

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

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

    have you tried 'category__in' => array(13,14)

  3. nathanael.montgomery
    Member
    Posted 2 years ago #

    I did, in fact, I finally found my answer, although I'm not sure exactly why it works,

    'portfolio_category' => 'Cat1'

    I figured it out after taking a look at this defined a little later in the code:

    echo "<li class=\"";
                $myterms = get_the_terms($post->ID,'portfolio_category');
                foreach ($myterms as $myterm ) {
                 echo $myterm->slug."\n";
                }
                echo "\">";

Topic Closed

This topic has been closed to new replies.

About this Topic