Behavior of the 'posts_search' filter has changed
-
In WordPress version 3.6.1 and earlier, the “posts_search” filter was applied unconditionally, i.e., even when the “s” query argument was empty. You can see this in lines 2215-2216 of wp-includes/query.php, which are outside the “if ( !empty($q[‘s’] ) )” block of code which precedes it.
In version ‘3.7-RC1-25851’, the ‘posts_search’ filter has been moved into a new function, “parse_search” (wp-includes/query.php lines 1917- 1971), which is only executed if the “$q[‘s’]” argument is not empty.
This makes it impossible for a plugin to add a search clause to a query which does not have one to begin with. It is a change in filter behavior from earlier versions, which state that the filter will “Allow plugins to contextually add/remove/modify the search section of the database query”.
Please move the filter back to its original location after the “if ( !empty($q[‘s’] ) )” block and before the “// Taxonomies” block which follows it.
- The topic ‘Behavior of the 'posts_search' filter has changed’ is closed to new replies.