Last active
June 11, 2018 18:42
-
-
Save ksascomm/88c084fffc9bbbf69308a4b2c2078efc to your computer and use it in GitHub Desktop.
Custom Query Vars + Mindbreeze Pagination
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 mindbreeze_query_vars_filter($vars) { | |
$vars[] = 'q'; | |
return $vars; | |
} | |
add_filter( 'query_vars', 'mindbreeze_query_vars_filter' ); | |
// pagination | |
$page = get_query_var( 'page', 1 ); | |
$site_path = site_url('/search'); | |
if ($body->resultset->prev_avail) : | |
$newPage = $page - 1 ; | |
$params = array('q' => $query, 'page' => $newPage);?> | |
<p><a href="<?php echo add_query_arg($params, $site_path);?>">PREV</a></p> | |
<?php elseif ($body->resultset->next_avail) : | |
$newPage = $page + 1 ; | |
$params = array('q' => $query, 'page' => $newPage);?> | |
<p><a href="<?php echo add_query_arg($params, $site_path);?>">NEXT</a></p> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment