I am using the pagenavi plugin for pagination but, I have a problem with sidebar Views.
I am using the code suggested by you and Caridad for setting the page number in functions.php.
In main content area of my page I am displaying a CPT. In right sidebar I have 3 widgets, each displaying a CPT with its own View and Content Template. The pagenavi numbers and Prev/Next all displays correctly and operates correctly. But, when I advance to the next "page" of CPT list, the widget display advances also. I am of course applying the page number using pagenavi_paged() function for each CPT. But, the logic is somehow wrong because the page number of the main View is also being used to paginate the sidebar widget CPTs, even though those Views are set to No Pagination. I tried debugging this in the functions by setting the View ID but I could not get that to make a difference. I think I need to add a check in the pagenavi_paged() function for current view = widget using view_id, but I don't know how to do this.
Here is my code in functions:
function pagenavi_paged($query) { if (in_array('cnsv_member_profiles', (array)$query->query_vars['post_type'] ) ) { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $query->query_vars['paged'] = $paged; return $query; } elseif ( (in_array('event', (array)$query->query_vars['post_type'] ) ) { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $query->query_vars['paged'] = $paged; return $query; } elseif (in_array('project', (array)$query->query_vars['post_type'] ) ) { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $query->query_vars['paged'] = $paged; } elseif ( (in_array('article', (array)$query->query_vars['post_type'] ) ) { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $query->query_vars['paged'] = $paged; } } add_filter('parse_query', 'pagenavi_paged'); // Add a custom wp_pagenavi shortcode function wpv_pagenavi($args, $content) { global $WP_Views; return wp_pagenavi( array('query' => $WP_Views->post_query, 'echo'=>false) ); } add_shortcode('wpv-pagination', 'wpv_pagenavi');
http://cnsv7g.wpengine.com/consultant-directory/
Click on Next and you will see the content for top 2 widgets disappear because there is no more posts for that type. The 3rd widget content advances to the next 3 posts.
So, on this particular page, I have 3 different CPTs: cnsv_consultant_profiles (main content area), event (widget), event (widget), article (widget).
Can you please tell me what is causing this or show me how to check for a widget View in pagenavi_paged()?
Thanks!
Jeff
——-