Shortcodes and AJAX content

Some themes and plugins may load your content using AJAX requests. In this case, shortcodes may not work properly, because wp_head and wp_footer hooks will not be triggered after the content load. This means that necessary shortcode assets (javascript and stylesheets) will not be loaded.

To fix this, you can force the loading of necessary assets on every page. Add the following code to the end of the functions.php file of your active theme:

function PREFIX_su_force_assets() {

  if ( ! function_exists( 'su_query_asset' ) ) {

  // Shortcode styles
  su_query_asset( 'css', 'su-shortcodes' );

  // Icons
  // For shortcodes with icons like spoiler or service
  su_query_asset( 'css', 'su-icons' );

  // Animations
  su_query_asset( 'css', 'animate' );

  // jQuery
  su_query_asset( 'js', 'jquery' );

  // Lightboxes
  // lightbox, exit_popup, splash_screen, image_carousel w/ lightbox
  su_query_asset( 'css', 'magnific-popup' );
  su_query_asset( 'js', 'magnific-popup' );

  // Shortcode scripts
  // tabs, spoiler, image_carousel, etc.
  su_query_asset( 'js', 'su-shortcodes' );

  // Extra Shortcodes add-on
  su_query_asset( 'css', 'owl-carousel' );
  su_query_asset( 'js', 'owl-carousel' );
  su_query_asset( 'css', 'shortcodes-ultimate-extra' );
  su_query_asset( 'js', 'shortcodes-ultimate-extra' );


add_action( 'wp_head', 'PREFIX_su_force_assets' );

Look for the complete list of available assets here:  /wp-content/plugins/shortcodes-ultimate/inc/core/assets.php:41.

🤝 Thank you!