I need some advice with this one. I want to load posts of certain years depending what year the user clicks, to achieve this I have the following:
<?php
$args = array(
'post_type' => 'post',
'ignore_sticky_posts' => 1,
'year' => '2015',
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="post-item" style="margin-bottom: 70px;">
<div class="post-info">
<p class="post-time">
<?php echo get_the_date(); ?>
</p>
<h2 class="post-title">
<?php the_title(); ?>
</h2>
<div class="post-content">
<?php the_content(); ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
with this I'm displaying all posts of 2015. My question is, how I could AJAXify this. I'm having different Buttons like a Menu with different years. And each querys a different year and displays it.
Thanks
Aucun commentaire:
Enregistrer un commentaire