I want to make a pagination of the results of the AJAX request. Pagination does not work. After clicking the page number, only the address and everything (example: / page / 3 /) change. Where did I make a mistake?
PAGE.PHP
<div class="site-content clearfix">
<h1>Alex Blog</h1>
<?php
$ourCurrentPage = get_query_var('paged');
$aboutPosts = new WP_Query(array(
'post_type' => 'tour',
'post_status' => 'publish',
'posts_per_page' => 3,
));
if ($aboutPosts->have_posts()) :
while ($aboutPosts->have_posts()) :
$aboutPosts->the_post();
?>
<span> <?php the_title(); ?> </span>
<br>
<?php endwhile;
echo paginate_links(array(
'total' => $aboutPosts->max_num_pages
));
endif;
?>
</div>
FUNCTION.PHP
function tourcat_ajax_by_order() { if (isset($_REQUEST)) {
$posts_per_page = et_get_option( 'divi_archivenum_posts' ) ;
$args = array( // WP query args
'post_type' => 'tour',
'post_status' => 'publish',
'posts_per_page' => $posts_per_page
);
$tour_query = new WP_Query($args);
if ( $tour_query->have_posts() ) { // Have posts start here
while ( $tour_query->have_posts() ) { // While starts here
$tour_query->the_post();
?>
<span> <?php the_title(); ?> </span>
<br>
<?php}
echo paginate_links(array(
'total' => $aboutPosts->max_num_pages
));}
else {
echo 'No results found';}
wp_reset_postdata();}
die();}
JS CODE
function tourcat_orderby_posts() {
$.ajax({
url: ajaxurl,
data: {
'action':'tourcat_ajax_by_order',
},
success: function(data) {
// This outputs the result of the ajax request
$(".tour_parent_div").html(data);
},
error: function(errorThrown) {}
});}