Home › Forums › Add-ons › Repeater Field › order acf repeater-field by datepicker in wp-query › Reply To: order acf repeater-field by datepicker in wp-query
if you dont try to merge your posts into one list you could try this:
<ul class="program-list">
<?php query_posts('cat=2'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
$repeater = get_field('program_repeater');
foreach( $repeater as $key => $row ) {
$thedate = $row['program_repeater_date'];
$column_id[ $key ] = strtotime($thedate);
}
array_multisort( $column_id, SORT_ASC, $repeater );
foreach( $repeater as $row ){
$dateDayNumber = date_i18n("d", strtotime(get_sub_field('program_repeater_date')));
$dateMonthNumber = date_i18n("m", strtotime(get_sub_field('program_repeater_date')));
$dateDayOrg = date_i18n("l", strtotime(get_sub_field('program_repeater_date')));
$dateDay = substr($dateDayOrg, 0, 2);
$dateTime = get_sub_field('program_repeater_time');
$specialEvent = get_sub_field('program_repeater_special');
$mainTitle = get_the_title();
$subTitle = get_field('sub_text');
$rowSeatsId = get_sub_field('program_repeater_rowseats_id');
?>
<li>
<div class="specialEvent"><?php if( $specialEvent ): ?><?php echo $specialEvent; ?><?php else: ?> <?php endif; ?></div>
<div class="dateDayNumber"><?php echo $dateDayNumber; ?></div>
<div class="dateMonthNumber"><?php echo $dateMonthNumber; ?></div>
<div class="dateDay"><?php echo $dateDay; ?></div>
<div class="v-line-zick-zack"></div>
<div class="dateTime"><?php echo $dateTime; ?></div>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<div class="mainTitle"><?php echo $mainTitle; ?></div>
<div class="subTitle"><?php echo $subTitle; ?></div>
</a>
<a href="<?php the_permalink(); ?><?php echo "?id=" . $rowSeatsId; ?>" title="<?php the_title_attribute(); ?>">
<div class="ticket-link">Tickets kaufen</div>
</a>
<div class="clear"></div>
</li>
<?php } ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</ul>
If you try to merge them => you need to build a array first, order it, and echo it after that.
try to adapt a solution like this or this
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.