• Resolved satisdee

    (@satisdee)


    Hello,

    How might I change the following code so that it outputs all posts that don’t include the tag ID of both 12 and 22?

    $my_query = new WP_Query('post_type=plants&posts_per_page=999&orderby=title&order=ASC&tag__not_in=12');
          while ($my_query->have_posts()) : $my_query->the_post();

    I have tried the following, but it doesn’t work:

    $my_query = new WP_Query('post_type=plants&posts_per_page=999&orderby=title&order=ASC&tag__not_in=12,22');
          while ($my_query->have_posts()) : $my_query->the_post();

    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I recommend using an array for your arguments to make it easier to read. So with your query try this instead:

    $args = array(
    	'post_type' => 'plants',
    	'posts_per_page' => 999, //if you intend to show all posts you can just use -1 here instead
    	'orderby' => 'title',
    	'order' => 'ASC	',
    	'tag__not_in' => array( 12,22 )
    );
    Thread Starter satisdee

    (@satisdee)

    Thank you Joms, that worked perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘tag__not_in for multiple tags?’ is closed to new replies.