I'm using a page as archive for a custom post type called event.
register_post_type('event', array(
'labels' => array(
'name' => 'Événements',
'singular_name' => 'Événement',
),
'public' => true,
'has_archive' => false,
'hierarchical' => false,
'menu_icon' => 'dashicons-calendar-alt',
'rewrite' => array(
'with_front' => false,
'slug' => 'evenements'
)
));
Then, I defined this page template to template-event.php, where I use the following code to loop through post types.
$args = array(
'post_type' => 'event',
'posts_per_page' => 6,
'paged' => get_query_var('paged')
);
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
the_title();
endwhile;
wp_pagenavi( array( 'query' => $the_query ) );
wp_reset_postdata();
endif;
?>
This code works great for my home.php page, but not for this one.
Any idea why?
meta_query
for showing only those which have a ACF date bigger than the current date.pre_get_posts
to alter main query arguments.slug/n/
, notslug/page/n/
, and query var ispage
what nstead ofpaged