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?
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.