Дата публикации : 2024.01.08
Автор:Виноградов Александр
Рейтинг статьи:
How to display Acf field group for a specific WordPress post or page
<?php
/* page (post) from which we display fields with fields (!status personal) /wp-admin/post.php?post=23105&action=edit */
/*post Video slider (see fig.) take by slug*/
$slider_config_page = get_page_by_path('video-na-glavnoj');
/* acf field group /wp-admin/post.php?post=23106&action=edit */
$fields = acf_get_fields( "23106" );
?>
<?php //iterate over an array of fields ?>
<?php foreach ( $fields as $field ): ?>
<?php //we get the fields of the post we need Video slider ?>
<?php $acf_field = get_field( $field['name'], $slider_config_page->ID ); ?>
<?php //get the values of each field ?>
<?php $vk_kod_video = $acf_field['vk_kod_video'] ?? null; ?>
<?php $prevyu_url = $acf_field['prevyu']['url'] ?? null; ?>
<?php endforeach; ?>