Hi, I have created a custom post type Event and created a custom arhive template to show all events (Featured Events will show first and than rest). The code I am using below.
<?php
// query events order
$posts = get_posts(array(
'posts_per_page' => 10,
'post_type' => 'event',
'meta_query' => array(
'date_clause' => array(
'key' => 'start_date',
'compare' => 'EXISTS'
),
'feature_clause' => array(
'key' => 'featured',
'compare' => 'EXISTS'
)
),
'orderby' => array(
'feature_clause' => 'DESC',
'date_clause' => 'ASC'
)
));
if( $posts ): ?>
<div class="events-list">
<?php foreach( $posts as $p ): ?>
<div><h2><a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo $p->post_title; ?></a></h2></div>
<div><?php the_field('start_date', $p->ID); ?></div>
<div><?php the_field('end_date', $p->ID); ?></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
Here events are more than 15 but it not showing pagination, please help on this how can i get pagination.
I am using this code <?php posts_nav_link(); ?>
to get the pagination but not working, I am trying to solve this from so many days but no result please help on this.
And I am displaying upcoming events in a seperate page using custom template file.
And I have taken the code from this resource – https://www.advancedcustomfields.com/resources/date-time-picker/
How to get working pagination for this? Please help.
Hi,
Is there any solution for this?