Searchable meta value in user.php
Searchable meta value in user.php
Searchable meta value in user.php
Lets break this down, Advanced Custom Fields (ACF) does save the data as custom field/post meta, I guess it seems all to obvious, but it is better to confirm it, and ElasticPress does set up custom fields automatically to include them into the search index. ElasticPress does this unless the meta data is hidden, which … Read more
To ignore dots (.) in the search parameter s, for all backend searches, we can use: /** * Ignore dots in all backend searches */ add_action( ‘pre_get_posts’, function( \WP_Query $q ) { if ( is_admin() && $q->is_search() ) $q->set( ‘s’, str_replace( ‘.’, ”, $q->get( ‘s’ ) ) ); } ); We can further restrict it … Read more
You could try unsetting the original search query, otherwise you may be doubling up and the combination results in nothing? eg, try adding to your function: $query->set(‘s’,”); UPDATE I am not sure on this one, but you could try the AND operator -I think this adds to the existing query instead of replacing it… function … Read more
You can add more than one filter call, so each of your custom meta_key‘s can be handled in separate code and when executed will cumulatively adjust the query. Perhaps look at the pre_get_posts filter rather than parse_query (although the solution I’m suggesting could possibly work in either case). pre_get_posts gives you access to the current … Read more
This is happening due to encoding. I assume you have a function in your search page, which you get and use search_text inside that template. You should decode the URL before doing so. The urldecode() function would be what you are looking for. Your string is also UTF-8 encoded, so this is what you are … Read more
SOLUTION: I will post my solution and explain what was the problem and I hope that this post can help someone in the future. As we talk in the small comments the problem, was that I was sending a non existing taxonomy by error and this was causing the AND (0=1). To fix the whole … Read more
Quick explanation Search is search and not an archive. If you’ll take a look at is_post_type_archive docs, you’ll see that it: Checks if the query is for an archive page of a given post type(s). So if you’re using this condition in your pre_get_posts, then it won’t affect search results at all. On the other … Read more
You can install the Query Monitor plugin to see what actual query that is being executed when you perform a search. I suspect the problem you are having is that you are not unsetting the initial query vars. You are adding the meta query, but you haven’t removed the s= parameter, which only searches for … Read more
Have you tried it with add_action instead of add_filter ? add_action(‘pre_get_posts’, ‘search_custom_fields’); Is public set to true for your post_type? And for use on in admin, try: if ( is_admin() && $query->is_main_query() ) { if ( $query->is_search ) { //etc.