Dimastik86
@Dimastik86
(isset($brain))?: die;

Кастомные поля (вывод инф), как сделать?

Прошу подсказать, где/как создать шаблоны для вывода карты с метками?
Поле добавить у меня получилось, инф сохраняется, а как вывести не пойму...

Вот это я не понял:
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


И вот это:
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


подробно тут

спасибо!
  • Вопрос задан
  • 38 просмотров
Решения вопроса 1
Dimastik86
@Dimastik86 Автор вопроса
(isset($brain))?: die;
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
mihdan
@mihdan
WordPress-евангелист, ведущий РНР - разработчик
Выводится как в статье, только хук другой 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
        }
}


Добавит карту в содержимое записи.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы