Skip Navigation

[Resolved] Filtering results does not update the count of results number

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user has added filters to the products archive template, but after filtering the pagination does not update.

Solution:
The user was referring to the default pagination from WooCommerce/WordPress instead of the archive template pagination. We'll need to remove the WooCommerce pagination and add pagination to the archive template. Check more details in these replies:

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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 7 replies, has 2 voices.

Last updated by michaelH-21 4 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#1780057

Tell us what you are trying to do?
At the top of the page there is a 'Showing 1-40 of X results'. When I apply a filter, it shows the filtered items, but the count at the top does not update X to show the correct number of results
Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

#1780267

Hello and thank you for contacting the Toolset support.

Please check if this issue appears when:
- Only Toolset plugins are activated. It will tell us if there is an interaction issue with another plugin.
- The theme is set to a WordPress default like TwentyTwenty. It will tell us if there is an interaction issue with your theme.
If the problem disappears, start activating one at the time to track where the incompatibility is produced. And we'll continue from there.

If the issues persist with only Toolset plugins and a default theme, I'll need to take a closer look at your view and check where the "counts" are being added in the view. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

If you share the credentials of your website, please let me know, if I can disable plugins and switch themes. If not, can you provide a test site to work on it? Or, I can take a Duplicator copy of your website and check it locally.

#1781407

It seems that the results count and the pagination are added by WooCommerce and they do not belong to the Toolset archive template that is being used. Check the following screenshot, you will notice that the results count and the pagination are outside of the archive. hidden link

I will suggest removing both with the following code, you will need to put it in your child theme's functions.php:

/**
 * Remove the result count from WooCommerce
 */
remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_result_count', 20 );

/**
 * Remove the pagination from WooCommerce
 */
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );

Please note, that I did not test this code. It may not work, depending on the theme's too. Let's try them and we'll see.

Then, I'll suggest adding the results count and the pagination in the archive template. You can use the user interface controls, which will translate into shortcodes. Or you can use the shortcodes directly. Read more about the views shortcodes here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

Let me know what you will get.

#1781685

Thank you. I was able to add this to functions.php and remove the default woo commerce count + pagination. I then went into the Loop Editor for my WordPress Archive and could add [wpv-pager-archive-nav-links] to get the pagination to show up. However, as I click through the pages, it doesn't change the highlighting of which page you're on in the pagination. It is still Page 1 that is highlighted. How can this be updated?

Also, with the results count, I am having an issue finding the proper shortcode to put into the Search and Pagination section so that this can display near my search filters. Can you help?

New threads created by Jamal and linked to this one are listed below:

https://toolset.com/forums/topic/pagination-items-styles-are-not-updating-when-going-through-pages/

#1781727

I found "Showing [wpv-items-count] of [wpv-found-count] results." in the shortcode, but the format I was wanting to implement was like

"Showing 1-40 of 90 results" then once you go to Page 2, it'd say "Showing 41-80 of 90 results".

And still having the pagination active issue.

#1781771

I wanted to check how is the template updated but the provided user/password are not working for me anymore. Your next reply will be private to let you share new credentials safely.

#1782557

There is no shortcode that will allow you to display "Showing 1-40 of 90 results" on the first page, then once you go to Page 2, displays "Showing 41-80 of 90 results".
So you will need to create a custom shortcode to do that.

I run a test and I come up with the following shortcode:

add_shortcode('pagination-formatted', 'pagination_formatted_func');

function pagination_formatted_func($atts, $content) {
  $atts = shortcode_atts( array(
    'current' => '1',
	'found'   => '0',
    'max'     => '10'
  ), $atts );
  
  $current = (int) $atts['current'];
  $found = (int) $atts['found'];
  $max = (int) $atts['max'];
  
  $result = ( $max * ($current - 1) ) + 1;
  $limit = ( $max * ( $current - 1) ) + $found;
  
  return "$result - $limit";
}

The shortcode will need 3 values to generate the desired outcome, the current page number, the number of found results in the current page, and the maximum number of results per page. I named them, respectively, "current", "found", and "max".
Then we could use the shortcode as follow:

Showing [pagination-formatted current="[wpv-pager-current-page force="true"]" found="[wpv-items-count]" max="40"] of [wpv-found-count] results.

Read the documentation of each one of the used shortcodes here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

However, for support rules, we are able to handle only one issue at the time. This helps us to bring you a better service and also helps other users to find all the information here exposed. For that reason, I have created another ticket to handle the issue of the pagination not updating. I'll be posting my replies there.

#1783331

My issue is resolved now. Thank you for going above and beyond to help!