Forums Forums Search & Filter Pro problem with shortcode and ajax reload

Viewing 8 posts - 1 through 8 (of 8 total)
  • Anonymous
    #248388

    Hello,

    I have a custom results.php. In this I load a shortcode:

    if (!empty(get_field('_smt-gallery-shortcode'))) {
    					$galleryShortcode = "[foogallery id=" . get_field('_smt-gallery-shortcode') . " paging_size=3]";
    					echo $galleryShortcode;
    					echo do_shortcode("$galleryShortcode");
    				 }

    When th page is loaded the first time everything works fine. When I change the filter and the page is reloaded (ajax on) the shortcode is not shown.

    When I diasble Ajax in the Search&Filter settings the whole page is reloaded and the shortcode is shown.

    What can I do to load the shortcode together with ajax refresh.

    Robert

    Trevor
    #248393

    What plugin does the shortcode come from? If it is using JavaScript to expand the shortcode, that would be why this is happening. Can you show me the full file?

    Please note that it is late here in the UK (gone 5PM) and we are closed now for the day, so I will likely not reply until tomorrow.

    Anonymous
    #248402
    This reply has been marked as private.
    Trevor
    #248518

    It certainly looks as though that is the issue. Are you able to contact the author and ask how the shortcode can be refreshed on an Ajax load of the content? We have a jQuery/JavaScript that any code can be embedded in (you can show them this, it will make sense to them:

    <script>(function ( $ ) {
      "use strict";
      $(document).on("sf:ajaxfinish", ".searchandfilter", function(){
        // call your script or function here
      });
    }(jQuery));</script>

    But …, looking at the code, this might do it:

    <script>(function ( $ ) {
      "use strict";
      $(document).on("sf:ajaxfinish", ".searchandfilter", function(){
        $('.foogallery').foogallery();
      });
    }(jQuery));</script>

    Assuming I have understood the problem, that the gallery isn’t working, yes?

    Anonymous
    #248559

    Thanks Trevor! I opened a ticket at Foo Plugin. I’ll keep you updated!

    Regarding the code: Shall I uses this in results.php?

    Robert

    Trevor
    #248561

    You can put it there, yes, but make sure it is outside of PHP.

    Anonymous
    #248573

    That’s working! Great! Thank you Trevor.

    I’ll keep you posted.

    Robert

    Trevor
    #248575

    Thanks for letting me know. I will close this thread for now.

Viewing 8 posts - 1 through 8 (of 8 total)