Skip to content

Instantly share code, notes, and snippets.

@Bobz-zg
Created August 25, 2016 10:11
Show Gist options
  • Save Bobz-zg/4ae8e610de4e86ac4e21a1938bf8e86c to your computer and use it in GitHub Desktop.
Save Bobz-zg/4ae8e610de4e86ac4e21a1938bf8e86c to your computer and use it in GitHub Desktop.
Filter WordPress posts by custom taxonomy term with AJAX
<?php
function vb_ajax_pager( $query = null, $paged = 1 ) {
if (!$query)
return;
$paginate = paginate_links([
'base' => '%_%',
'type' => 'array',
'total' => $query->max_num_pages,
'format' => '#page=%#%',
'current' => max( 1, $paged ),
'prev_text' => 'Prev',
'next_text' => 'Next'
]);
if ($query->max_num_pages > 1) : ?>
<ul class="pagination">
<?php foreach ( $paginate as $page ) :?>
<li><?php echo $page; ?></li>
<?php endforeach; ?>
</ul>
<?php endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment