Skip Navigation

[Resolved] Allow user to select number of view results returned

This support ticket is created 4 years, 3 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 1 reply, has 2 voices.

Last updated by Minesh 4 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1469703

Hi there,

I need to allow the users on my website to select how many results a View shows - for example a dropdown with 20 / 50/ ALL in there allowing the user to select how many he wants to see on the page.

Is this possible natively? If not is there an example that's already been suggested on Toolsets forum that you know of?

Many thanks

#1470425

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

No - there is no such feature available to change the number of posts to be displayed.

The workaround would be to use view's filter hook "wpv_view_settings" to change the limit dynamically. You should try to add a dropdown to select the number of posts 5,10,15,20,25.... with such values and add the submit button to the "Search and Pagination" section and adjust the number of post limit with the following hook.

For example:
<codde>
//Modify the limit and/or offset settings of a given View to use a number greater than 50:
add_filter( 'wpv_view_settings', 'func_modify_post_limit', 5, 2 ); // use a low priority number of 5, so this runs early
function func_modify_post_limit( $view_settings, $view_id ) {
if ( $view_id == 9999 ) { // if displaying a View with ID equal to 9999
$view_settings['limit'] = 100; // show 700 posts

}
return $view_settings;
}
[/php]
Where:
- Replace 9999 with your original view ID.

More info:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_view_settings

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.