{"id":33819,"date":"2019-03-01T09:56:47","date_gmt":"2019-03-01T09:56:47","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33819"},"modified":"2019-10-21T06:30:02","modified_gmt":"2019-10-21T06:30:02","slug":"ajax","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/ajax\/","title":{"rendered":"Shortcodes and AJAX content"},"content":{"rendered":"\n<p>Some themes and plugins may load your content using AJAX requests. In this case, shortcodes may not work properly, because&nbsp;<code>wp_head<\/code>&nbsp;and&nbsp;<code>wp_footer<\/code>&nbsp;hooks will not be triggered after the content load. This means that necessary shortcode assets (javascript and stylesheets) will not be loaded.<\/p>\n\n\n\n<p>To fix this, you can force the loading of necessary assets on every page. Add the following code to the end of the&nbsp;<em>functions.php<\/em>&nbsp;file of your active theme:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function PREFIX_su_force_assets() {\n\n  if ( ! function_exists( 'su_query_asset' ) ) {\n    return;\n  }\n\n  \/\/ Shortcode styles\n  su_query_asset( 'css', 'su-shortcodes' );\n\n  \/\/ Icons\n  \/\/ For shortcodes with icons like spoiler or service\n  su_query_asset( 'css', 'su-icons' );\n\n  \/\/ Animations\n  su_query_asset( 'css', 'animate' );\n\n  \/\/ jQuery\n  su_query_asset( 'js', 'jquery' );\n\n  \/\/ Lightboxes\n  \/\/ lightbox, exit_popup, splash_screen, image_carousel w\/ lightbox\n  su_query_asset( 'css', 'magnific-popup' );\n  su_query_asset( 'js', 'magnific-popup' );\n\n  \/\/ Shortcode scripts\n  \/\/ tabs, spoiler, image_carousel, etc.\n  su_query_asset( 'js', 'su-shortcodes' );\n\n  \/\/ Extra Shortcodes add-on\n  su_query_asset( 'css', 'owl-carousel' );\n  su_query_asset( 'js', 'owl-carousel' );\n  su_query_asset( 'css', 'shortcodes-ultimate-extra' );\n  su_query_asset( 'js', 'shortcodes-ultimate-extra' );\n\n}\n\nadd_action( 'wp_head', 'PREFIX_su_force_assets' );<\/code><\/pre>\n\n\n\n<p>Look for the complete list of available assets here:&nbsp;&nbsp;<a href=\"https:\/\/github.com\/vanokhin\/shortcodes-ultimate\/blob\/master\/inc\/core\/assets.php#L94\">\/wp-content\/plugins\/shortcodes-ultimate\/inc\/core\/assets.php:41<\/a>.<\/p>\n","protected":false},"featured_media":0,"template":"","docs_category":[22],"class_list":["post-33819","docs","type-docs","status-publish","hentry","docs_category-troubleshooting"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33819"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}