[wp-trac] [WordPress Trac] #7798: tag__not_in doesn't seem to work in filters

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 27 00:23:02 GMT 2008


#7798: tag__not_in doesn't seem to work in filters
------------------------+---------------------------------------------------
 Reporter:  gmorehoudh  |       Owner:  anonymous
     Type:  defect      |      Status:  new      
 Priority:  normal      |   Milestone:  2.7      
Component:  General     |     Version:           
 Severity:  normal      |    Keywords:           
------------------------+---------------------------------------------------
 I'm attempting to exclude posts with a certain tag from feeds under
 certain conditions.  I'm using {{{tag__not_in}}}, but many more posts are
 disappearing from the feed than are tagged with the particular tag.  I've
 double-checked the tag ID in the database and the manage tags page in the
 admin interface, so it's not incorrect in my code.


 {{{
 function hide_noaff_posts_from_feed($post) {
         global $query_string;
         if(is_feed()) {
                 $vars = parse_str($query_string);
                 $vars['tag__not_in'] = array(28);       // 28 is the id of
 the 'noaff' tag in the terms table
                 query_posts($vars);
         }
 }

 [...]

 add_action('loop_start', 'hide_noaff_posts_from_feed');
 }}}

 and

 {{{
 function fff($query) {
         $query->set('tag__not_in', array(28));

         return $query;
 }

 [...]

 add_filter('pre_get_posts', 'fff');
 }}}

 Neither of these work properly.  They exclude many posts, but I've only
 tagged one with the tag with id 28.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7798>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list