Home › Forums › General Issues › Past Events Page, Display Posts by DatePicker Year › Reply To: Past Events Page, Display Posts by DatePicker Year
@codeview muchas gracias! i have my own thing going now and it works,
I am now at the next step where i need to add a condition from a group switch to the mix (group/solo). I have the code, I just don’t know how to merge it in. Perhaps you have some advice.
Most grateful in any case
This is where I am at:
<?php if (have_posts()) : ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$today = date('Ymd');
$past_args = array(
'paged' => $paged,
'posts_per_page' => -1,
'post_type' => 'exhibition',
'meta_query' => array (
array (
'key' => 'ex_start',
'value' => $today,
'compare' => '<',
'type' => 'DATE'
)
),
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
query_posts( $past_args );
?>
<?php
echo '<div class="biotitle">' . 'Solo Exhibitions' . '</div>';
?>
<!-- PAST EXHIBITIONS -->
<?php while (have_posts()) : the_post(); ?>
<?php
$date = get_field('ex_start');
$gallery = get_field('ex_gallery_name');
$past_year = DateTime::createFromFormat('Ymd', $date);
$year = $past_year->format('Y');
// get start date
$datum1 = get_field('ex_start', false, false);
// make start date object
$datum1 = new DateTime($datum1);
// get end date
$datum2= get_field('ex_end', false, false);
// make end date object
$datum2 = new DateTime($datum2);
if ($year !== $today) { ?>
<h2><?php echo $year; ?></h2><p><br /></p><p><br /></p>
<?php } ?>
<a href="<?php the_permalink(); ?>" class="exhibit"><?php the_title(); ?> , <?php echo $gallery; ?> , <?php echo $datum1->format('j M Y'); ?> - <?php echo $datum2->format('j M Y'); ?></a>
<?php $today = $year; ?>
<?php
echo "<p><br /></p>";
?>
<?php endwhile; ?>
<?php endif; ?>
and this is my final argument, that i am to inexperienced to merge in:
<?php
$posts = get_posts(array(
'meta_query' => array(
array(
'key' => 'ex_groupsolo', // name of custom field
'value' => 'solo',
)
)
));
if( $posts ) {
//...
}
?>
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!
ACF’s Repeater field is a versatile solution for repeating content in #WordPress.
— Advanced Custom Fields (@wp_acf) December 29, 2022
What’s your favorite use case for the Repeater field?
What’s the weirdest thing you’ve ever used it for?
Let us know!👇
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.