Home › Forums › Add-ons › Repeater Field › List posts grouped by sub-field of repeater › Reply To: List posts grouped by sub-field of repeater
for now I have this:
<?php
$args = array(
‘posts_per_page’ => -1,
‘post_type’ => ‘eventos’,
‘status’ => ‘programa’,
‘orderby’ => array(
‘title’ => ‘ASC’)
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<hr>
<?php the_field(‘evento-viagem’); ?> / <?php the_field(‘evento-audiencia’); ?><br>
“><?php the_title(); ?><br>
<?php if( get_field(‘evento-subtitulo’) ): ?>
<?php the_field(‘evento-subtitulo’); ?><br>
<?php endif; ?>
<?php the_field(‘evento-caminho’); ?> <?php the_field(‘evento-ano’); ?><br>
<?php if( have_rows(‘evento-paragens’) ): ?>
<?php
$posts = get_sub_field(‘evento-local’);
if( $posts ): ?>
<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
<?php echo get_the_title( $p->ID ); ?> <?php the_field(‘local-cidade’, $p->ID); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php endwhile; ?>
wich Outputs something like this:
DAY 1 — HOUR — EVENT A — CITY
DAY 1 — HOUR — EVENT A — CITY
DAY 2 — HOUR — EVENT A — CITY
DAY 2 — HOUR — EVENT A — CITY
DAY 1 — HOUR — EVENT B — CITY
DAY 1 — HOUR — EVENT B — CITY
DAY 2 — HOUR — EVENT B — CITY
DAY 2 — HOUR — EVENT B — CITY
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.