Created
August 25, 2016 10:11
-
-
Save Bobz-zg/4ae8e610de4e86ac4e21a1938bf8e86c to your computer and use it in GitHub Desktop.
Filter WordPress posts by custom taxonomy term with AJAX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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