M
M
mt. NATS2020-05-29 09:56:50
WordPress
mt. NATS, 2020-05-29 09:56:50

Custom fields (output inf), how to do?

Please tell me where / how to create templates for displaying a map with labels?
I managed to add the field, the info is saved, but I don’t understand how to display it ...

I didn’t understand this:

Display Single CPT Map Field
So first if you are also displaying the Google Map as a single map on the dealer CPT you'll need to output the custom location map field and fire the JS and API files – here I am adding this code directly in the CPT template – so in my single-dealer.php


And here it is:
Display Multiple Markers in one map for all CPT dealer posts
I have created a custom page page-all-dealers.php which I am outputting one map with all the markers using a while loop




thank you in detail !

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mt. NATS, 2020-05-29
@Dimastik86

done through snippets

M
Mikhail Kobzarev, 2020-05-29
@mihdan

It is displayed as in the article, only the hook is different the_content:

add_action( 'the_content', 'themeprefix_add_marker' ); // Hook in the field
// ACF Google Map Single Map Output
function themeprefix_add_marker() {

        $location = get_field('location');  // Set the ACF location field to a variable

        if( !empty($location) ) {
        ?>
                <div class="acf-map">
                        <div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>">
                                <h4><a href="<?php the_permalink(); ?>" rel="bookmark"> <?php the_title(); ?></a></h4> <!-- Output the title -->
                                <p class="address"><?php echo $location['address']; ?></p> <!-- Output the address -->
                        </div>
                </div>
        <?php
        }
}

Adds a map to the post content.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question