Hi, I've a Blocks View, it had custom search filters and pagination. I've been working with it and I removed the pagination.
Now I want to activate pagination again, but when I try to add the pagination block I get an error (see image).
This is a test page with a copy of my view:
/wp-admin/post.php?post=2247&action=edit
Can you help me?
cheers
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Umberto,
Thanks for getting in touch.
Would you mind if I took a copy of this site to test locally here as well ?
Please let me know.
Thanks,
Shane
Yes, you can, but I've to say that in the mean while I've rebuilt the view with pagination and now it works on the live page.
What I was trying to do with pagination is this:
https://toolset.com/forums/topic/remove-pagination-on-search-submit/
I tried the suggested custom code, but it is triggered when the view is first load, so it just remove pagination. I just want to remove pagination on search submit. Is it possible? Can I add a conditional to check if the user is running the search?
Here you can check the new view I built /tableau-de-bord/. I've added the PHP code in Toolset>Settings>Custom code>custom-view.
cheers
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Umberto,
Happy to see that it now works.
If I understand correctly you only want the code below to be triggered after the user has performed a search ?
add_filter( 'wpv_filter_query', 'func_set_posts_per_page', 99, 3 );
function func_set_posts_per_page( $query_args, $view_settings, $view_id ) {
$views = array( 99999);
if ( in_array( $view_id, $views ) ) {
$query_args['posts_per_page'] = 999;
}
return $query_args;
}
Please let me know.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Umberto,
Please try the code below now.
add_filter( 'wpv_filter_query', 'func_set_posts_per_page', 99, 3 );
function func_set_posts_per_page( $query_args, $view_settings, $view_id ) {
$views = array( 99999);
if ( in_array( $view_id, $views ) && isset($_GET['wpv_view_count'])) {
$query_args['posts_per_page'] = 999;
}
return $query_args;
}
It should only trigger when a search is performed.
Thanks,
Shane
Hi, I've tried your code, but the problem is that also pagination uses wpv_view_count parameter:
/tableau-de-bord/?wpv_aux_current_post_id=209&wpv_aux_parent_post_id=209&wpv_view_count=2252&wpv_paged=3
I get a page without results when I click on any pagination link.
cheers
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Umberto,
I've made the adjustments to the code and it should now be working.
add_filter( 'wpv_filter_query', 'func_set_posts_per_page', 99, 3 );
function func_set_posts_per_page( $query_args, $view_settings, $view_id ) {
$views = array( 2252 );
if ( in_array( $view_id, $views ) && (isset($_GET['wpv_view_count']) && !isset($_GET['wpv_paged'])) ) {
$query_args['posts_per_page'] = 999;
}
return $query_args;
}
I've added an additional check to ensure that the code doesn't run if the wpv_paged value is set.
Thanks,
Shane