Support

Account

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 🙂