I am trying to get page navigation going, for posts which are displayed as an ajax response.
I'm not sure exactly how to accomplish this.
Here is some code to look at.
$posts_per_page = 6;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$pageposts = query_posts(
array(
'post_type' => 'post',
'cat' => intval($_POST['pageCategory']),
'paged' => $paged,
'posts_per_page' => $posts_per_page,
));
if ($pageposts):
$response = '';
foreach ($pageposts as $post):
$postId = get_the_ID();
$postPermalink = get_the_permalink($postId);
$postTitle = get_the_title();
$response .= '
<article class="gridView col-lg-4 col-md-6 col-xs-12">
<div class="list-article-thumb" style="background: url('; if ( get_the_post_thumbnail_url() == false ) { $response .= get_stylesheet_directory_uri() . '/images/placholder2.png'; } else { $response .= get_the_post_thumbnail_url(); } $response .= ') no-repeat; height: 445px; background-size: cover; position: relative;">
</div>
</article>
';
endforeach;
$response .= wp_pagenavi();
wp_reset_query();
else :
$response = '
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn\'t here.</p>
';
endif;
The page navigation is returned as part of the ajax request but when I click on the next page button it goes to that page, rather than sending another request to ajax-posts.php
Cheers ol mates