Answer the question
In order to leave comments, you need to log in
How to fix ajax pagination when loading posts via ajax?
In general, I made a widget on the archive page that displays taxonomy elements and, when clicked, displays posts via ajax. The difficulty is that pagination breaks, which, for any request other than query_posts, refuses to appear at all, and with it loads the same posts that are already loaded (duplicates).
Post output and pagination code:
<div id="blog-list" <?php if ( $exm1_category_post_style == 'style_1' ){echo 'class="blog-category"';}elseif( $exm1_category_post_style == 'style_2' ){echo 'class="exm1-blog-posts-category"';}elseif( $exm1_category_post_style == 'style_3' ){echo 'class="img-featured"';}?>>
<ul>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<li>
<?php if ( $exm1_category_post_style == 'style_1' ){
category_post_style1($author_show, $date_show);
}elseif( $exm1_category_post_style == 'style_2' ){
category_post_style2($author_show, $date_show);
}elseif( $exm1_category_post_style == 'style_3' ){
category_post_style3($author_show, $date_show);
}?>
</li>
<?php endwhile; else : ?>
<div class="widget-title"><?php echo esc_html(get_option('exm1_no_match')); ?></div>
<?php endif;?>
</ul>
</div>
<?php $exm1_pagination_style = get_option('exm1_pagination_style');if($exm1_pagination_style =='ajax' || $exm1_pagination_style =='auto-load' ){?>
<div class="pagination pagination-load-more <?php if($exm1_pagination_style =='auto-load'){echo esc_attr('auto-load');}?>">
<?php $loadmoreword = get_option('exm1_word_load_more');
next_posts_link(esc_html($loadmoreword), '' ); ?>
</div>
<!--pagination-->
<?php } else { ?>
<div class="pagination-simple">
<?php exm1_pagination(); ?>
</div>
<!--pagination-simple-->
<?php } ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question