Search custom post type posts only by meta fields?

This might work, not tested though. First add this to join the postmeta table: add_filter( ‘posts_join’, ‘search_filters_join’, 501, 2 ); function search_filters_join( $join, $query ) { global $wpdb; if ( empty( $query->query_vars[ ‘post_type’ ] ) || $query->query_vars[ ‘post_type’ ] !== ‘product’ ) { return $join; // skip processing } if ( ($this->is_ajax_search() || $this->is_search_page()) && … Read more

Why is WordPress wrapping search for users that looks like integers with asterisks and how do I fix it?

The search term was getting surrounded by asterisks. Yes, and they are wildcard characters, and in the case of the Users list table at wp-admin/users.php, those asterisks are being added by wp-admin/includes/class-wp-users-list-table.php (see source on GitHub for WordPress v6.1), so that a LIKE ‘%<keyword>%’ query is performed by default. So to fix the issue, yes, … Read more

Disable – Post search field – for non-admin roles in WP dashboard

There is no straight forward documented way of removing the search box in the admin panel’s Post dashboard (wp-admin/edit.php). However, it’s still possible by extending WP_Posts_List_Table class. Additionally, it makes sense that if you remove the search box, you’d also like to disable the search capability all together (based on your requirement). In that case, … Read more