Skip Navigation

[Resolved] Remove pagination on search submit

This support ticket is created 2 years, 8 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 2 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2334159

Hi, I've a Block View with search filters and pagination.

I'd like to remove pagination on search submit, I need to display all the results on the same page, not paginated. But I still want pagination when results are not filtered.

Is it possible?

I've also another issue with the same view. I'm displaying publish, draft and pending posts, but when I run a search, the view displays only publish posts in the result. Is it possible to include all the posts?

cheers

#2334213

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You should try to use the view's hook "wpv_filter_query" to change the posts_per_page and increase the limit of it based on any URL param available when you do the 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;
}

To hide the pagination links, you should wrap the pagination section with conditional block and use the shortcode [wpv-search-term param='any-param'] to see if the URL param exists or not and based on that you should display the pagination section.

For example, please check the following screenshot: hidden link
- The pagination will display if URL param search is equal to empty.

#2334239

Thank you, I will try this solution. I also mentioned another issue:

I've also another issue with the same view. I'm displaying publish, draft and pending posts, but when I run a search, the view displays only publish posts in the result. Is it possible to include all the posts?

cheers

April 5, 2022 at 9:34 am

#2334325

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you try to add a query filter from the "Content Selection" tab of your view and add a post status filter. Please check the following screenshot: hidden link