I have a search form for a custom post type. The user should be able to search by name of the store and the city where the store is located The name of the store is the same as the title of the post, so Ive managed to figure that part out. The city on the other hand is an advanced custom field, and I can't figure out how to include this in the search query. So when the user starts to type, is it a match with 1. the post title and/or 2. the advanced custom field "city"?
This is my code in functions.php
And the html is as simple as this:
<input type="text" name="keyword" id="keyword" onkeyup="fetch()"></input> <div id="datafetch">Search results will appear here</div>
This code works as long as the user search for the title of store. How do I manage to include a custom field as an argument (sorry this might be the wrong word but I cant find the right one) to the
I found this example, and I tried it but just got an error saying that
cf_search_join couldn't be found. And at the same time didn't really manage to understand the code... Is this the more right approach? Or can I build something from what I already have?
** UPDATED QUERY **
$the_query = new WP_Query( array( 'posts_per_page' => -1, 's' => esc_attr( $_POST['keyword'] ), 'post_type' => 'aterforsaljare', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'vendor_city', 'value' => 'value', 'compare' => 'LIKE', ) ) ) );