Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to get ACF Repeater field values from the parent page
// Get the id of the parent page
$pid = wp_get_post_parent_id( get_the_ID() );
// Use $pid in get_post_meta() to get the repeater field (will return number of rows)
$page_more_products_child = get_post_meta($pid, 'page_more_products', true);
if( $page_more_products_child ) { // GET ACF Repeater field data from another page
for ($i=0; $i<$page_more_products_child; $i++) {
$graphic_id_meta_key = 'page_more_products_'.$i.'_pmp_graphic';
$subtitle_meta_key = 'page_more_products_'.$i.'_pmp_subtitle';
$description_meta_key = 'page_more_products_'.$i.'_pmp_description';
$link_meta_key = 'page_more_products_'.$i.'_pmp_link';
$graphic_id = get_post_meta($pid, $graphic_id_meta_key, true);
$graphic = wp_get_attachment_image($graphic_id, 'more-products');
$subtitle = get_post_meta($pid, $subtitle_meta_key, true);
$description = get_post_meta($pid, $description_meta_key, true);
$link = get_post_meta($pid, $link_meta_key, true);
<div class="product">
<a href="<?php echo $link; ?>">
<div class="image-wrap">
<?php echo $graphic; ?>
<div class="content-wrap">
<h3><?php echo $subtitle; ?></h3>
<p><?php echo wp_trim_words($description, 12, ''); ?></p>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.