Yeah, our Views pagination URL is ugly.
It produces stuff like `example.com/type/?wpv_view_count=147-TCPID79&wpv_paged=2`
This is required for several features, as example AJAX pagination might not work if you do not use above URL format (which is native to Views)
What one can do is customize this a bit.
You need this Plugin:
Then this code in your theme’s functions.php:
// Get the page number into wp_pagenavi
function pagenavi_paged($q) {
$types = (array)$q->get('post_type');
if (in_array('test', $types)) {
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$q->set('paged', $paged);
}
}
add_action('pre_get_posts', 'pagenavi_paged');
// create pagination shortcode
function custom_pagenavi($args, $content) {
global $WP_Views;
wp_pagenavi( array('query' => $WP_Views->post_query) );
}
add_shortcode('custom-pagination', 'custom_pagenavi');
If you do not restrict this on post types, then use this:
// Get the page number into wp_pagenavi
function pagenavi_paged($q) {
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$q->set('paged', $paged);
}
add_action('pre_get_posts', 'pagenavi_paged');
// create pagination shortcode
function custom_pagenavi($args, $content) {
global $WP_Views;
wp_pagenavi( array('query' => $WP_Views->post_query) );
}
add_shortcode('custom-pagination', 'custom_pagenavi');
Keep in mind that this is custom code that we cannot debug or provide in-depth explanations and customizations.