简体   繁体   中英

Fancybox custom div show/hide

I have a custom post type in Wordpress that creates a gallery of images (unordered list) that open in fancybox. I created a dynamic div of a sold label within the fancybox JavaScript that appears on the left corner of the image in the lightbox across from the close button. I only want the label to show if the image is within the category "sold". Is there a way to do this?

For anyone who is interested, I figured this out on my own. I added the category slug to the fancybox link class like this: <?php theme_get_categories($post->ID, 'gallery_category', ' ', 'slug'); ?> <?php theme_get_categories($post->ID, 'gallery_category', ' ', 'slug'); ?>

Then I created a fancybox helper for that class in my javascript file that creates a new wrapper for that class like this:

tpl: { wrap : '<div class="fancybox-wrap fancybox-desktop fancybox-type-image fancybox-opened" tabIndex="-1"><div class="fancybox-skin"><div id="sold-label" class="sold-label"><h2>Sold</h2></div><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>' },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM