Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#7798 closed defect (bug) (invalid)

tag__not_in doesn't seem to work in filters

Reported by: gmorehoudh Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


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


add_action('loop_start', 'hide_noaff_posts_from_feed');


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.

Change History (7)

#1 @gmorehoudh
13 years ago

This behavior also appears to be happening with categorynot_in.

#2 @gmorehoudh
13 years ago

And also with $query->set('cat', '-29');

The various methods for filtering certain posts based on tag or category appears to be totally broken in 2.6.2. I can't find any other explanation. I've deleted other category-related plugins (that weren't even active) and disabled all my other filter functions, but any time I tell Wordpress, with a filter, to exclude posts in certain categories or with certain tags, it also excludes a bunch of posts that do not meet the criteria.

#3 @gmorehoudh
13 years ago

I've partially figured out what is happening here. Posts aren't actually improperly disappearing. Instead, they are being spit out in an apparently random order, instead of descending by date as they should be. When I scrolled back through all the older entries on the blog's home page, the posts appeared to be all there but completely in the wrong order, both on the main blog and the feed.

#4 @Otto42
13 years ago

I'd lay odds that this is the #7226 problem.

#5 @gmorehoudh
13 years ago

We are going to upgrade to 5.0.67 and will report back if this solves the problem.

#6 @gmorehoudh
13 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Upgrading to MySQL 5.0.67 has solved this issue. The posts appearing in semi reversed, semi random order upon attempting to exclude a category or tag is a bug in MySQL, not Wordpress. This was a duplicate of #7226.

See also

#7 @lloydbudd
13 years ago

  • Milestone 2.7 deleted
Note: See TracTickets for help on using tickets.