Skip Navigation

[Résolu] Problem with shortcode in AJAX pagination

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

Problem: I have a View that paginates with AJAX. A specific shortcode included on the first page works fine. However, the same shortcode included on one of the following pages is written out in code.

Solution: There are some limitations to pagination with AJAX and 3rd-party shortcodes. If you created the shortcode yourself, you can use the Toolset Code Snippets feature to allow execution in AJAX requests.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-pagination/#limitations-of-using-ajax-pagination

This support ticket is created Il y a 5 années et 10 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 4 réponses, a 2 voix.

Dernière mise à jour par toolset-dave Il y a 5 années et 10 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1189841

Hi,

I have a pagination with manual transition and AJAX on lien caché and when the other page reloads, my shortcode which shows a reading time will not work, it display only name of the shortcode. How can i make it work?

#1189949

It may or may not be possible with AJAX, because there are some limitations with 3rd-party shortcodes and AJAX. The most practical solution is to not use AJAX. Otherwise, you may have to rewrite the shortcode in a way that will work with AJAX.
https://toolset.com/documentation/user-guides/views-pagination/#limitations-of-using-ajax-pagination

Is this custom shortcode something you developed yourself, or part of a plugin / theme you purchased?

#1189987

I am using this code:

<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
function reading_time() {
    $content = get_post_field( 'post_content', $post->ID );
    $word_count = str_word_count( strip_tags( $content ) );
    $readingtime = ceil($word_count / 200);

    if ($readingtime == 1) {
      $timer = " minuta";
    } else {
      $timer = " minuty";
    }
    if ($readingtime >= 5) {
      $timer = " minut";
    }
    $totalreadingtime = $readingtime . $timer;

    return $totalreadingtime;
}
add_shortcode( 'doba_cteni', 'reading_time' );

I have the shortcode inside Toolset setting as a snippet and when I was looking for the code, I saw checkbox Run context - AJAX calls. I turned it on now and it works 🙂

#1189994

Great! Let me know if you run into problems with the snippet system.

#1190324

My issue is resolved now. Thank you!