Admin menu search query changed

When creating and editing menus in the Menus interface, searching for posts and pages has historically used a full text search as a query. This can make some pages difficult to find, if they use a title that primarily uses common words in the site content.

In WordPress 6.9, the search query arguments have been changed to limit searches to only the post title. This is intended to make it easier to find the post you’re looking for in search results.

The query change adds the argument search_columns with the value array( ‘post_title’ ) to the search. The columns correspond to the database columns in the wp_posts table.

To facilitate sites that may need the previous search logic, a filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. has been added to easily modify the search query.

/** * Filter the menu quick search arguments. * * @since 6.9.0 * * @param array $args { *     Menu quick search arguments. * *     @type boolean      $no_found_rows          Whether to return found rows data. Default true. *     @type boolean      $update_post_meta_cache Whether to update post meta cache. Default false. *     @type boolean      $update_post_term_cache Whether to update post term cache. Default false. *     @type int          $posts_per_page         Number of posts to return. Default 10. *     @type string       $post_type              Type of post to return. *     @type string       $s                      Search query. *     @type array        $search_columns         Which post table columns to query. * } */ $query_args = apply_filters( 'wp_ajax_menu_quick_search_args', $query_args );

To restore the previous behavior, you can unset the additional argument:

/** * Restore pre-6.9 menu search arguments. * * @param array $args Array of arguments as documented. * * @return array */ function restore_menu_quick_search_args( $args ) {     unset( $args['search_columns'] );     return $args; } add_filter( 'wp_ajax_menu_quick_search_args', 'restore_menu_quick_search_args' );

Related ticketticket Created for both bug reports and feature development on the bug tracker.: Improve the “Add item” function in menus.

Acknowledgements

Props to @jorbin for reviewing this post.

#6-9, #dev-notes, #dev-notes-6-9