ACF Google Map Query for Bricks Map WIdget

Hi All

Try to migrate a map from elementor/plugin site to bricks
it’s for CPT that uses the ACF Google Map field

The Bricks widget says i can only use Lat & Long for multiple entries - unfortunately there are over 700 entries with only ACF Google Map field data :no_mouth: !

Not really sure how to get round this limitation?

This is the goal - the current elementer version that uses an horrendous plugin

https://scalapublishers.com/publish-with-us/

Yeah im looking for a solution for this. When i was using Elementor i just need to set the adress and thats it. So when people fill a form with the adress automaticly map was update.

But now with LAT and Long is harder to set, and if you already have the info to 100 CPT or more is harder to use the widget and update.

1 Like

I’ve not tested this in combination with bricks, but you can save the Lat & Long values in hidden ACF fields. With this code, you would need to save all 700 entries again, so maybe choose something different than ‘save_post’ to trigger the action for the first time…

Create two hidden fields:
map_lat and map_lng

Copy this code in the functions.php file of your child theme:

function acf_save_lat_lng( $post_id ) {

	// get value of ACF map field
	$value = get_field( 'map_adresse' );  // replace map_adresse with your ACF field name
	global $post;
	
	// update lat and lng as separate custom fields
	update_post_meta( $post->ID, 'map_lat', $value['lat'] );
	update_post_meta( $post->ID, 'map_lng', $value['lng'] );
}

// run after ACF saves the $_POST['acf'] data
add_action('save_post', 'acf_save_lat_lng', 20);

If you don’t mind buying a plugin, you could also use WP Gridbuilder. It has a very good map add-on. :slight_smile:

1 Like

HI @simone

Thanks for that, super helpful. :pray:
Seems like a good way to go! I’ll get testing.

I guess save_post action will be good going forward so that users will just carry on using the street address as usual.

I’m not sure what other actions i can use to do the initial conversion - i’ll investigate unless someone is kind enough to let me know!

If it helps anyone else decide, Bricks support didn’t mention anything on the roadmap to change the Long/Lat query loop limitation.

WP Grid builder has been on my radar - i’ve been a long time Search & FIlter Pro user, but perhaps it’s time to change.

Kinda sad, since i dont want to use another plugin. Already use like 15 and thats to huge. and more if i use woocommerce like 20. ill check that plugin, thanks.