Plugin is breaking meta_query
-
We’ve been using SEO Framework on a site for quite a while now without any problems. With version 2.9.3, we did notice a problem with one of our site functions. We’ve got a home-made “related posts” function that uses WP_Query with a meta_query argument (with “OR” relation”) to display a few posts.
With 2.9.3, however, the meta query is no longer working and all posts are returned. Here’s the SQL that’s generated by WP_Query with SEO Framework disabled:
SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( ( wp_postmeta.meta_key = 'agents_0_agent' AND wp_postmeta.meta_value = '21294' ) ) AND wp_posts.post_type = 'property' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order ASC
Here’s the SQL that’s generated by WP_Query with SEO Framework enabled (returns all posts)
SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id AND mt1.meta_key = 'exclude_from_archive' ) WHERE 1=1 AND ( ( wp_postmeta.meta_key = 'agents_0_agent' AND wp_postmeta.meta_value = '21294' ) OR ( mt1.post_id IS NULL ) ) AND wp_posts.post_type = 'property' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order ASC
I’ve verified that reverting to version 2.9.2 fixes the problem.
**Update** I did a little searching and found https://github.com/sybrew/the-seo-framework/issues/167
Disabling the search filters did the trick:
add_action( 'init', function() { $tsf = function_exists( 'the_seo_framework' ) ? the_seo_framework() : null; if ( isset( $tsf ) ) { remove_action( 'pre_get_posts', array( $tsf, 'adjust_search_filter' ), 9999 ); remove_action( 'pre_get_posts', array( $tsf, 'adjust_archive_query' ), 9999 ); } } );
Any thoughts on if this is a permanent change or if it will be reverted at some point?
- The topic ‘Plugin is breaking meta_query’ is closed to new replies.