Hi sybrew,
Quick and dirty: Running into a site search conflict when SEO Framework is active that returns 0 content for any s= and from what I can tell it's because of the meta_query arrary that gets set in search.class.php LN 82. I think. Maybe.
Long explanation below, b/c I'm not sure exactly what's going on and code about as well as a caveman with a keyboard. So I manage a site that lives within a WP Multisite within a university environment that has some custom post types and ACF fields. Our multisite admin introduced me to SEO Framework at some point earlier this year and quickly came to appreciate the level of control it provided.
One of our homebrew cpts is a course post that uses ACF for session/date info and an shared all posttype 'Location' taxonomy to create a targeted search for just courses with some options to filter. Initially I was using Ultimate WP Search Query Filter plugin to generate this and embed, but apparently on our multisite AJAX is locked down, and the search won't function for non-University logged in users, which was an issue since our courses are for public at large/industry segments. Sitewide search worked fine, though I could never get UWPSQF to use the non-AJAX search results option, so had to dump it and try building a custom search.
Thus I set to cobbling together a search form that throws filter options via url to a custom search.php for the course post_type and then hits the loop with whichever arguments are provided. Things looked dandy testing in my dev space and when I pushed the theme updates to production, search didn't return anything.
So dumping wp_query on both I ended up with the logs here:
multidev-shingo-wp-query.txt
production-shingo-wp-query.txt
So I see the main differences between the two as:
`
https://multidev.eos.ncsu.edu/ncjones4/?s=shingo
MultiDev's request:
[request] => SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_17_posts.ID FROM wp_17_posts LEFT JOIN wp_17_postmeta ON wp_17_posts.ID = wp_17_postmeta.post_id WHERE 1=1 AND (((wp_17_posts.post_title LIKE '%shingo%') OR (wp_17_postmeta.meta_value LIKE '%shingo%') OR (wp_17_posts.post_excerpt LIKE '%shingo%') OR (wp_17_posts.post_content LIKE '%shingo%'))) AND wp_17_posts.post_type IN ('post', 'page', 'attachment', 'courses', 'staff', 'project', 'tribe_venue', 'tribe_events') AND (wp_17_posts.post_status = 'publish' OR wp_17_posts.post_status = 'acf-disabled' OR wp_17_posts.post_status = 'private') ORDER BY wp_17_posts.post_title LIKE '%shingo%' DESC, wp_17_posts.post_date DESC LIMIT 0, 5
[posts] => Array ( ...
https://www.ies.ncsu.edu/?s=shingo&debug
Production's request:
[request] => SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_15_posts.ID FROM wp_15_posts LEFT JOIN wp_15_postmeta ON (wp_15_posts.ID = wp_15_postmeta.post_id AND wp_15_postmeta.meta_key = 'exclude_local_search' ) LEFT JOIN wp_15_postmeta ON wp_15_posts.ID = wp_15_postmeta.post_id WHERE 1=1 AND (((wp_15_posts.post_title LIKE '%shingo%') OR (wp_15_postmeta.meta_value LIKE '%shingo%') OR (wp_15_posts.post_excerpt LIKE '%shingo%') OR (wp_15_posts.post_content LIKE '%shingo%'))) AND (
(
wp_15_postmeta.post_id IS NULL
)
) AND wp_15_posts.post_type IN ('post', 'page', 'attachment', 'courses', 'staff', 'project', 'stlr_place', 'tribe_venue', 'tribe_events') AND (wp_15_posts.post_status = 'publish' OR wp_15_posts.post_status = 'acf-disabled' OR wp_15_posts.post_author = 35 AND wp_15_posts.post_status = 'private') GROUP BY wp_15_posts.ID ORDER BY wp_15_posts.post_title LIKE '%shingo%' DESC, wp_15_posts.post_date DESC LIMIT 0, 5
[posts] => Array
(
)
Post meta appears in the dump in a couple of spots on Production::
LN 108
[meta_query] => Array
(
[0] => Array
(
[0] => Array
(
[key] => exclude_local_search
[value] => 1
[type] => CHAR
[compare] => NOT EXISTS
[relation] => AND
)
)
)
...
LN 168
[meta_query] => WP_Meta_Query Object
(
[queries] => Array
(
[0] => Array
(
[0] => Array
(
[key] => exclude_local_search
[value] => 1
[type] => CHAR
[compare] => NOT EXISTS
[relation] => AND
)
[relation] => OR
)
[relation] => OR
)
[relation] => AND
[meta_table] => wp_15_postmeta
[meta_id_column] => post_id
[primary_table] => wp_15_posts
[primary_id_column] => ID
[table_aliases:protected] => Array
(
[0] => wp_15_postmeta
)
[clauses:protected] => Array
(
[wp_15_postmeta] => Array
(
[key] => exclude_local_search
[value] => 1
[type] => CHAR
[compare] => NOT EXISTS
[relation] => AND
[alias] => wp_15_postmeta
[cast] => CHAR
)
)
[has_or_relation:protected] =>
)
[date_query] =>
...
`
And when I deactivate SEO Framework and voila, search starts returning things in production again.
So obvs I failed to notice SEO Framework wasn't activated in multidev. Okay. And for some reason &debug doesn't work on multidev, but I dropped a print_r( $wp_query ); in the search.php so I could get the log there.
None of the content in the site has exclude_local_search enabled.
So, not sure why the value of that key is being set as 1. And I'd like to keep using the SEO Framework plugin. I don't anticipate we'd need to hide anything in the site from search, so what I'd kinda like to test is maybe overriding that value to always 0 and testing multidev to see if that's enough to fetch results.
Alternatively I may have done something stupid with search.php and search-courses.php such that's conflicting with SEO Framework, but I don't immediately see it. I've stuck the child theme on my personal git here https://github.com/ndyjones/ies-divi-child if it helps track whatever the hell I've done.
Any insights or help you could provide would be much appreciated.