Home › Forums › ACF PRO › Google maps search › Reply To: Google maps search
Hi @twizzlebird
You can always query the posts based on custom fields. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/.
You can use the $_GET variable for the search keyword and use it like this:
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'cpt',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'google_map',
'value' => $_GET['location'],
'compare' => 'LIKE',
),
),
));
The URL should be something like this: http://example.com/path-where-you-put-the-code/?location=locationkeyword
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.