[wp-trac] [WordPress Trac] #20092: Add Exclude by Tag to Queries

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 22 06:28:52 UTC 2012


#20092: Add Exclude by Tag to Queries
-------------------------+------------------------------
 Reporter:  iridox       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Query        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+------------------------------

Comment (by iridox):

 That would make sense. The way I've been achieving this filter so far is
 hooking into the pre_get_posts filter like so:


 {{{
 function exclude_tags_rss($query) {
         if ( $query->is_feed) {
                 if( isset($_GET['tag__not_in']) ) {
                         $qv = $_GET['tag__not_in'];
                         if( strpos($qv, ',') !== false) $tag =
 explode(',', $qv);
                         else $tag[] = $qv;
                 }
                 $query-> set('tag__not_in', $tag);
         }
 return $query;
 }
 add_filter('pre_get_posts','exclude_tags_rss');
 }}}

 There must be a better way to do this...

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20092#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list