Робота з ACF (Advanced Custom Fields)

Last update: 22 Квітня, 2023

Category: WordPress

Повторители полей

<?php
    if (have_rows("имя_поля_повторителя")) {
        while (have_rows("имя_поля_повторителя")) {
            if ( get_sub_field('имя_поля_в_повторителе') ) {
                the_sub_field("имя_поля_в_повторителе");
            }
        }
    }
?>

 

 

https://only-to-top.ru/blog/programming/2019-05-11-vyvod-proizvolnyh-polej-acf.html

 

<?php /* Template Name: gallery */ ?>

<?php

echo $phone_number = get_field('phone_number', url_to_postid( 'contacts' ));
echo $phone_link = 'tel:+'.str_replace(array("+", " ", "-", "(", ")"), "", $phone_number);
echo get_field('e_mail', url_to_postid( 'contacts' ));
echo 'mailto:'.get_field('e_mail', url_to_postid( 'contacts' ));
echo get_field('address', url_to_postid( 'contacts' ));
echo get_field('link_for_navigator', url_to_postid( 'contacts' ));

echo get_field('viber', url_to_postid( 'contacts' ));
echo get_field('telegram', url_to_postid( 'contacts' ));
echo get_field('whatsapp', url_to_postid( 'contacts' ));
echo get_field('facebook', url_to_postid( 'contacts' ));
echo get_field('instagram', url_to_postid( 'contacts' ));
echo get_field('youtube', url_to_postid( 'contacts' ));

?>

<?php ?>
<div>
    tel <a href="<?php echo 'tel:+'.str_replace(array("+", " ", "-", "(", ")"), "", get_field('phone_number', url_to_postid( 'contacts' ))); ?>"><?php echo get_field('phone_number', url_to_postid( 'contacts' )); ?></a>
</div>
<div>
    mail <a href="<?php echo 'mailto:'.get_field('e_mail', url_to_postid( 'contacts' )); ?>"><?php echo get_field('e_mail', url_to_postid( 'contacts' )); ?></a>
</div>
<div>
    address <a href="<?php echo get_field('link_for_navigator', url_to_postid( 'contacts' )); ?>"><?php echo get_field('address', url_to_postid( 'contacts' )); ?></a>
</div>

FB for page 404
<div>
    <div>SK <?php echo get_field('facebook', '44'); ?></div>
</div>
<div>
    <div>other <?php echo get_field('facebook', '43'); ?></div>
</div>
<div>
    <div></div>
</div>