WordPress.org

Ready to get started?Download WordPress

Forums

Check if post has gallery (1 post)

  1. CDSanchez
    Member
    Posted 5 years ago #

    Is there any way to check if a post has a gallery? I'm using a plugin that adds a jquery thickbox to galleries.. but it loads jQuery and the thickbox scripts on every page even though posts with galleries are the only pages that will use those javascripts. I don't want my users to download something they might not need during their visit

    I was thinking of doing something like:

    if (do_shortcode('[gallery]')) {
     //load javascripts
    }

    or

    if (!empty(do_shortcode('[gallery]')) {
     //load javascripts
    }

    Would that work? I don't want to mess with anything and break it inadvertently.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.