Title: Excluding Posts With Tag Using query_posts
Last modified: August 19, 2016

---

# Excluding Posts With Tag Using query_posts

 *  Resolved [justbishop](https://wordpress.org/support/users/justbishop/)
 * (@justbishop)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-with-tag-using-query_posts/)
 * Anyone know why this isn’t working? No errors or anything, but the posts tagged“
   blog” and “gallery” are still showing:
 *     ```
       <?php 
   
                       $term = get_term_by('slug','blog', 'post_tag');
       				$term2 = get_term_by('slug','gallery', 'post_tag');
       				$args=array(
         					'tag__not_in' => array($term->term_id, $term2->term_id),
         					'post_type' => 'post',
         					'post_status' => 'publish',
         					'caller_get_posts'=> 1
       				);
   
                       query_posts(array('tag__not_in' => array($args)));
   
                       if (have_posts()) : ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [justbishop](https://wordpress.org/support/users/justbishop/)
 * (@justbishop)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/excluding-posts-with-tag-using-query_posts/#post-1797424)
 * Got it, thanks Kawaouso in #wordpress IRC!
 *     ```
       <?php 
   
                       $term = get_term_by('slug','blog', 'post_tag');
       				$term2 = get_term_by('slug','gallery', 'post_tag');
       				$args=array(
         					'tag__not_in' => array($term->term_id, $term2->term_id),
         					'post_type' => 'post',
         					'post_status' => 'publish',
         					'caller_get_posts'=> 1,
         					'paged' => $paged
       				);
   
                       query_posts($args);
   
                       if (have_posts()) : ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Excluding Posts With Tag Using query_posts’ is closed to new replies.

## Tags

 * [Exclude tags](https://wordpress.org/support/topic-tag/exclude-tags/)

 * 1 reply
 * 1 participant
 * Last reply from: [justbishop](https://wordpress.org/support/users/justbishop/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/excluding-posts-with-tag-using-query_posts/#post-1797424)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
