• Resolved DoodleDogCody

    (@doodledogcody)


    I use a plugin on a lot of my sites that modifies the normal [gallery] shortcode.

    On a current site, I would still like this to occur on every page on the site except for a specific post type.

    I was thinking that I could do something like this.

    if( !is_singular('custom-post-type') ) {
       add_shortcode('gallery', 'shortcode_function');
    }

    But this does not stop the new gallery shortcode function from firing. Is this possible to do at all? If so, can someone help point my in the right direction?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Despite similarity in naming, the function for adding shortcodes is nothing like adding filters or actions. If you have custom gallery code anyway, your best bet is to alter that code to return an empty string if that particular post type is the queried object. The default gallery will then be used.

    This is assuming the new gallery code is invoked by hooking the ‘post_gallery’ filter, which is the usual way to override the default gallery.

    Thread Starter DoodleDogCody

    (@doodledogcody)

    thanks for the feedback. The plugin author wasn’t doing this the correct way, they were simply ovveriding the gallery shortcode by calling add_shortode(‘gallery’, plugin_function); which fires off after the original add_shortcode to the gallery. I have modified it though and fixed my problem.

    thanks for the help

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditionally adding shortcodes’ is closed to new replies.