gallery shortcode is called twice
-
Hey, great plugin. I’m working on a new version of my own plugin (Responsive Gallery Grid) and I created a hook like this to modify the gallery:
add_filter( 'post_gallery', 'rgg_gallery_shortcode', 9, 2 );
The problem is that the post_gallery filer is called twice per gallery. When I disable all plugins (mine included) except yours, I see that your plugin is calling the function
gallery_shortcode()
inwp-includes/media.php
twice, causingapply_filters( 'post_gallery', '', $attr, $instance );
to be run twice as well.This is a bit of a problem for me, as I need to set some JS parameters for each shortcode. The thing is, there are 2 cases in which the same code is run.
Case 1: your plugin is installed and there is only one gallery
Case 2: A user includes the same gallery twice in a single pageBoth these cases will trigger the exact same gallery_shortcode function, with the exact same parameters, twice. In the first case, however the JS parameters that are set will refer to 2 galleries while there is only one gallery.
Is there no way you could modify your code so the
apply_filters('post_gallery')
will not be called a second time?Or would you suggest that I overwrite the gallery shortcode in another way?
- The topic ‘gallery shortcode is called twice’ is closed to new replies.