You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
global $post;
$content = $post->post_content;
// Load assets if in post content.
if ( has_shortcode( $content, 'gs_faq' ) ) {
Genesis_Simple_FAQ()->assets->enqueue_scripts();
}
This is really limiting IMO. What if we want to use the shortcode in a meta field in php via do_shortcode()? (sidenote, there should be a template tag for php)
The scripts are already registered globally in the register_scripts() method. Great.
Why not just enqueue them inside the shortcode? I do that all the time, and that insures the script always loads any time the shortcode is used, instead of guessing/hoping it's in the content.
So, inside the Genesis_Simple_FAQ_Shortcode class -> shortcode() method, after if ( $faqs->have_posts() ) { should be Genesis_Simple_FAQ()->assets->enqueue_scripts();
In Mai Theme we use a CMB2 repeater field (meta) to initially store each section content. That's when we found out the shortcode doesn't work in a section.
The text was updated successfully, but these errors were encountered:
@JiveDig thanks for sharing, saved me having to write it. Came across this issue today with a customer trying to use the shortcode in a front page widget.
Right now it's using this:
This is really limiting IMO. What if we want to use the shortcode in a meta field in php via do_shortcode()? (sidenote, there should be a template tag for php)
The scripts are already registered globally in the
register_scripts()
method. Great.Why not just enqueue them inside the shortcode? I do that all the time, and that insures the script always loads any time the shortcode is used, instead of guessing/hoping it's in the content.
So, inside the
Genesis_Simple_FAQ_Shortcode
class ->shortcode()
method, afterif ( $faqs->have_posts() ) {
should beGenesis_Simple_FAQ()->assets->enqueue_scripts();
In Mai Theme we use a CMB2 repeater field (meta) to initially store each section content. That's when we found out the shortcode doesn't work in a section.
The text was updated successfully, but these errors were encountered: