Problem: I would like to show the number of posts along with the Next and Previous page buttons in my pagination.
Solution: Add a custom shortcode like so:
add_shortcode( 'custom_page_results_count', 'custom_page_results_count_func'); function custom_page_results_count_func($atts) { $direction = intval($atts['direction']); $numresults = $atts['numresults']; $currentpage = $atts['currentpage']; $postsperpage = $atts['postsperpage']; $numberofpages = $atts['numpages']; if($currentpage + $direction == $numberofpages) { $mod = $numresults % $postsperpage; return $mod ? $mod : $postsperpage; } return $postsperpage; }
Then in your Filter editor, place your custom shortcode like so for Previous results:
[wpml-string context="wpv-views"]Previous [custom_page_results_count direction="-1" numresults="[wpv-found-count]" currentpage="[wpv-pager-current-page]" postsperpage="5" numpages="[wpv-pager-total-pages]"] Results[/wpml-string]
Replace the postsperpage value with the number of posts per page as found in your View's pagination settings. Note the direction "-1" for previous results - we'll use "1" for next results.
Then you can place the same custom shortcode with direction="1" like so for Next results:
[wpml-string context="wpv-views"]Next [custom_page_results_count direction="1" numresults="[wpv-found-count]" currentpage="[wpv-pager-current-page]" postsperpage="5" numpages="[wpv-pager-total-pages]"] Results[/wpml-string]
Again, replace the postsperpage value with the number of posts per page.
Relevant Documentation: https://toolset.com/documentation/toolset-training-course/part-4-pagination/
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by bobA-2 7 years ago.
Assisted by: Christian Cox.