Skip to content

Instantly share code, notes, and snippets.

@mennwebs
Created December 15, 2019 07:49
Show Gist options
  • Select an option

  • Save mennwebs/b890dccfe3306deedf0b98cf48f3f1ca to your computer and use it in GitHub Desktop.

Select an option

Save mennwebs/b890dccfe3306deedf0b98cf48f3f1ca to your computer and use it in GitHub Desktop.
ACF Repeater Headlines
<?php
/**
* ACF Repeater Field : headlines
* ACF Sub Field: headline (Post ID)
*/
$posts = array();
if (have_rows('headlines')) {
while (have_rows('headlines')) {
the_row();
array_push($posts, get_sub_field('headline'));
}
}
$args = array(
'post__in' => $posts,
'orderby' => 'post__in'
);
$the_query = new WP_Query($args);
while ($the_query->have_posts()) {
$the_query->the_post();
get_template_part('template-parts/content', 'headline');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment