Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Subhash, set the option to “First Image link” and it will auto-open the first image. But be aware that if there is another image link placed before the gallery on that same page then that one will be opened on page load instead.

    Thread Starter Subhash.at

    (@subhashat)

    Hi Ravan, setting the option to “First Image link” will auto-open the first image on every page. I would like to open it only on some. So either I want to set it to “First Image link” and exclude some pages or set it to “Auto-open: Link with ID ‘fancybox-auto'” and set “auto-open first image link” only on some pages. I think both should be possible with “add_shortcode” adding a function with a piece of javascript. How should this piece look like?

    Hmmm… then revert to “Link with ID ‘fancybox-auto'” and try the following script on any page where you want the first gallery image to open automatically:

    <script type="text/javascript">
    jQuery(".gallery-icon a").first().attr("id","fancybox-auto");
    </script>

    This code snippet must come AFTER the gallery (I’m assuming here you’re using the default WordPress galleries) but BEFORE the wp_footer() call which is usually in the theme footer.

    If you have trouble with the code being stripped out from the post editor by WordPress or the WYSIWYG editor, then you could place it in a sidebar Text widget and use Jetpack’s Widget Visibility module to control on which pages that widget gets added.

    Thread Starter Subhash.at

    (@subhashat)

    Works perfect! Many thanks!
    fineart-fotografie.at/still-living-beings

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to auto-open a WP gallery?’ is closed to new replies.