Skip Navigation

[Resolved] Pagination block error

This support ticket is created 2 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Shane 2 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#2408573
Captura de pantalla 2022-06-30 160332.jpg

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

#2408619

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

#2408661

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

#2408685

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

#2408727

Yes, correct.

#2409337

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

#2409381

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

#2409451

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