• Resolved joekhartley

    (@joekhartley)


    Hey!

    Great plugin – I just found a unique use case where the gallery scripts don’t get loaded, which means the lightbox doesn’t pop up.

    I have a Custom Post Type (‘Service Gallery’), into which I have placed a Gutenberg gallery element. That CPT is then selected via dropdown on another CPT (‘Service’) and as a consequence the Service Gallery CPT Content is loaded into a custom-created sidebar widget from within the theme I’m creating (allows me to load the gallery in a specific place in the layout).

    When a gallery is loaded in like that, your plugin seems to skip the ‘Enqueue assets’ code as it doesn’t recognise that there is a gallery on the page. (has_block() etc only check the main Post content)

    I certainly know this isn’t a bug so I’m not asking for it to be ‘fixed’, but it’s an interesting use case I thought you may want to know in case it’s something you want to cater for ??

    Take care!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Johannes Kinast

    (@goaroundagain)

    Hi @joekhartley,

    you can enqueue the script and style on every page with this function:

    function my_theme_enqueue_baguettebox_assets() {
    	wp_enqueue_script( 'baguettebox' );
    	wp_enqueue_style( 'baguettebox-css' );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_baguettebox_assets' );

    It would be even better if you run …

    wp_enqueue_script( 'baguettebox' );
    wp_enqueue_style( 'baguettebox-css' );

    … in your widget.

    Thread Starter joekhartley

    (@joekhartley)

    Yep, That’s what I ended up doing ?? Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Unqueued Scripts when using Gallery in a Widget’ is closed to new replies.