• Resolved nicktrosnant

    (@nicktrosnant)


    This is a great plugin.

    My problem is that the plugin tries to be efficient and only load the JavaScript on pages where it is relevant. It does this by running a number of has_block() checks. But this only works on the global $post object.

    So if you have page rendered using a page template that runs custom queries then the check may result in the JavaScript not being loaded where in fact it is needed as the image blocks are displayed as a result of a custom query.

    A workaround is to disable the checks (line 20 of gallery-block-lightbox.php) to force the JavaScript to load on all pages. But of course this won’t survive the next update to the plugin. I wonder if there is a better solution?

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

    (@goaroundagain)

    Hi,

    you can enqueue the script and style by running the following on your template:

    wp_enqueue_script( 'baguettebox' );
    wp_enqueue_style( 'baguettebox-css' );
    Thread Starter nicktrosnant

    (@nicktrosnant)

    Thanks for the superfast response.
    I have a number of page templates where this would be an issue.
    Do you think it would be a reasonable option to add that to functions.php and make it load everywhere that way?

    Plugin Author Johannes Kinast

    (@goaroundagain)

    Sure, just add this for your functions.php:

    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' );
    Thread Starter nicktrosnant

    (@nicktrosnant)

    Thank you. Done. Working fine. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to get it working on pages using custom queries’ is closed to new replies.