Admin page search is broken, why ?
-
Hi WordPress developers !
I have issues with my admin search, in page dashboard. /wp-admin/edit.php?post_type=page.
1. When I search something, results are no longer ordered with match in title first, then in content.
2. When I set the dashboard to show alot of pages (100+) so I can see the parent / children structure more clearly without pagination : I can’t even search for something. Hitting the search button does nothing.
3. Partially related : recently, some pages are missing from Parent Page under Page attributes. (When you start to type and get a suggestion list to select from). – this could be a question on it’s own.
The issues seems to occur only in the page dashboard, posts search results are fine.
Every pages are ordered in a parent / children structure, up to 3-4 childrens. I have 400+ pages.
The theme is custom, I’m in local dev environment (WAMP), the issue still happens when I deactivate all plugins (Anyway, plugins are : Yoast, ACF PRO, Redirections and Regenerate Thumbnails).
All my dashboard / custom post types / columns extensions are inserted via include() in functions.php
Even If I comment every include() – Which concretely means I deactivate all features – the problems still occurs.
The GET query looks normal.
/wp-admin/edit.php?s=mysearchquery&post_status=all&post_type=page&action=-1&m=0&seo_filter&readability_filter&paged=1&action2=-1
If I alter the query like this :
if ( is_admin() ) { add_filter( 'posts_search', 'search_by_title_only', 500, 2 ); } function search_by_title_only( $search, $wp_query ) { // $wp_query was a reference global $wpdb; if ( empty( $search ) ) { return $search; } // skip processing - no search term in query $q = $wp_query->query_vars; $n = ! empty( $q['exact'] ) ? '' : '%'; $search = $searchand = ''; foreach ( (array) $q['search_terms'] as $term ) { $term = esc_sql( $wpdb->esc_like( $term ) ); $search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')"; $searchand = ' AND '; } if ( ! empty( $search ) ) { $search = " AND ({$search}) "; if ( ! is_user_logged_in() ) { $search .= " AND ($wpdb->posts.post_password = '') "; } } return $search; }
I get only match from title (my problem 1 is solved, but I give up match from content…). And I have the feeling that starting to fix things like that could become a mess. More so if the desired behavior should be the default when installing WordPress.
Can you help me with tips, impressions, experiences ?
Thanks alot !
Best regards,
- The topic ‘Admin page search is broken, why ?’ is closed to new replies.