Description

At present when is_main_query() is called within the pre_get_posts hook, it returns a _doing_it_wrong() error which refers to replacing it with WP_Query::is_main_query(). Obviously it's saying call the method on the WP_Query object, but some people can take that literally and call it statically.

Notice: is_main_query was called incorrectly. In pre_get_posts, use the WP_Query::is_main_query() method, not the is_main_query() function.

We should instead, make mention to checking the passed $query object via $query->is_main_query() instead somehow.

Attachments (1)

Change History (10)

Maybe something like In pre_get_posts, use the $query->is_main_query() (WP_Query::is_main_query) method, not the is_main_query() function.. Leaves the function name there for those that want it, but removes the () to indicate you're not meant to call it.