Skip Navigation

[Résolu] Problem with [wpv-items-count] and Infinite Scroll

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I would like to show the total number of results shown on the page in a View that uses Infinite Scrolling, but the wpv-items-count shortcode is not updated when more results are added by Infinite Scrolling.

Solution: The wpv-items-found shortcode isn't designed to be used with automatic pagination or Infinite Scrolling. The only way to do this is to use custom JavaScript that hooks into the pagination event. Add a unique ID to the span around the wpv-items-count shortcode:

Отображается <span id="current-list-count">[wpv-items-count]</span> боев из [wpv-found-count]

Then in the View's Search and Pagination JS editor, add the custom event code:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
        count = jQuery('.fight-item').length;
    jQuery('#current-list-count').text( count );
});

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-count

0% of people find this useful.

This support ticket is created Il y a 6 années et 3 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par Max Il y a 6 années et 3 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1091906

Max

I am trying to: display correct value of displayed posts using shortcode [wpv-items-count]

Link to a page where the issue can be seen:
lien caché

I expected to see: The counter is growing

Instead, I got: The counter displays the same value (most likely because of Infinite Scroll)

#1092349

The wpv-items-found shortcode isn't designed to be used with automatic pagination or Infinite Scrolling. The only way to do this is to use custom JavaScript that hooks into the pagination event. Add a unique ID to the span around the wpv-items-count shortcode:

Отображается <span id="current-list-count">[wpv-items-count]</span> боев из [wpv-found-count]

Then in the View's Search and Pagination JS editor, add the custom event code:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
        count = jQuery('.fight-item').length;
	jQuery('#current-list-count').text( count );
});

From the Views shortcode documentation https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-count:

When using pagination, this value will be limited by the page size and the number of remaining results.

#1092358

Max

Thank you, Christian!