Home Forums ACF PRO Default marker for maps Reply To: Default marker for maps

  • Hi Doug,

    You can achieve it by using the acf/save_post hook and the update_field() function like this:

    function my_acf_default_map( $post_id ) {
        $selector = 'google_map_field_name';
        // get new value
        $value = get_field($selector, $post_id);
        if( !$value ){
            $value = array(
                "address" => "218 Abeckett St, Melbourne VIC 3000, Australia",
                "lat" => "-37.81025862543725",
                "lng" => "144.95670318603516"
            update_field($selector, $value, $post_id);
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_default_map', 20);

    But if you only need the address, which is basically a text, then you can always use the text field and set the default value on the backend instead.

    I hope this helps 🙂