[resolved] How to query posts category ID AND has tag ID? (3 posts)

  1. sem101
    Posted 4 years ago #

    Hi, thanks for helping. I'm so close...

    I have a basic Page template that outputs rows of Posts within a Category. I'm trying to also have this page output rows that are inside the Category and are Tagged.

    This works but only with a single tag_id. It will show tag 77, but 77,88 doesn't work:

    This works if I just want to output posts by tag but no category:
    query_posts( array('tag__in' => array(77,88)) );

    I feel like I'm 95% there, but can't figure out how to query_posts that are Category ID 1,2,3 and has Tag ID 77,88.

    Appreciate all help, thanks!

  2. Ross Hanney
    Posted 4 years ago #


    This should do the trick:

    query_posts( array( 'tag__in' => array( 77, 88 ), 'category__in' => array( 1, 2, 3 ) ) );
  3. sem101
    Posted 4 years ago #

    Thank you Ross! It works!

Topic Closed

This topic has been closed to new replies.

About this Topic