I just noticed a new error message on one of my websites' pages that lists posts, / :
Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /home/wp_gmz28r/clubcorvettect/wp-includes/functions.php on line 4138
This site has been running properly for several months. I tried adding code that was suggested in this forum
dd_action('pre_get_posts', function( \WP_Query $q ) {
if ( ! is_admin() // Only target the front-end
&& $q->is_main_query() // Target the main query
&& $q->is_search() // Target a search query
) {
// do stuff
}
})
but it didn't help. Any ideas?
I just noticed a new error message on one of my websites' pages that lists posts, http://clubcorvettect.com/category/events/ :
Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /home/wp_gmz28r/clubcorvettect.com/wp-includes/functions.php on line 4138
This site has been running properly for several months. I tried adding code that was suggested in this forum
dd_action('pre_get_posts', function( \WP_Query $q ) {
if ( ! is_admin() // Only target the front-end
&& $q->is_main_query() // Target the main query
&& $q->is_search() // Target a search query
) {
// do stuff
}
})
but it didn't help. Any ideas?
Hey Mike and welcome to the WordPress Stack Exchange!
First, it's good form to always include the code you use (or a link to where you found it) if you mention it in your post.
This error comes up when you use it prior to the search being run. The WordPress Codex doesn't have a ton of detail, but the basic gist is this: the function is very light weight and only returns a boolean. The reason it must be after the query is because it will always return false as it is checking wp_query() which doesn't exist until a query is run.
Unless your installation is aged and was recently updated, this error has probably been there for a while.
If the site is functioning the way you want, you can find the offending code and remove it since it's not in the right place anyways.