Support » Themes and Templates » How to query posts category ID AND has tag ID?

  • Resolved sem101

    (@sem101)


    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:
    query_posts('cat=1,2,3,4&tag_id=77,88');

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ross Hanney

    (@rosshanney)

    Hello,

    This should do the trick:

    query_posts( array( 'tag__in' => array( 77, 88 ), 'category__in' => array( 1, 2, 3 ) ) );
    sem101

    (@sem101)

    Thank you Ross! It works!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to query posts category ID AND has tag ID?’ is closed to new replies.