Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7281
    RTDCreative
    Participant

    Hi Guys,

    Absolutely love this plugin, so simple and I use it on pretty much every WordPress job I do. Normally I have no issues what so ever, but this current project is causing me issues.

    I have a custom post type called “Products” and I have a custom page template called “Bracelets”. The braclets custom template is calling in a query which searches for a particular featured image. The code I have for this part is as follows

    <a href="<?php the_permalink(); ?>" rel="lightbox"><?php the_post_thumbnail('product-image');?></a>

    As this is a featured image I thought it would need the link to itself adding in order to initialise the lightbox. I also added in the rel=”lightbox” part also. However when an image is clicked it simply takes it to the attachment page and does not open the lightbox.

    I have no errors appearing in Chrome Developer Tools it just simply is ignoring the images.

    Can anybody suggest anything or indeed a help for this as I have been racking my brains for hours. I have removed the link and rel tag in the code. I have de-activated all plugins bar this one. Most plugins I use tend to me 99% the same everytime so it isn’t a conflict.

    Be really great if I could get this fixed as the site is almost ready to go live.

    Cheers

    Dan

    #7311
    RTDCreative
    Participant

    Has anybody got a clue why the lightbox won’t work on Custom Post Type Featured Images??????

    #7312
    RTDCreative
    Participant

    After playing around and some Googling I have got a fix for my issue, so I thought I would share it.

    If anybody needs to display a Lightbox on a Featured Image, whether it be in a custom post type or not, a couple of things I did to sort my issues were as follows.

    1. Do Not check the box for conditional loading – it doesn’t seem to conditionally load the script in custom post types.

    2. Add the following code where you wish your featured image to appear. Replacing the YOUR-CUSTOM-THUMB with whatever name you have given your add_image_size() in your themes functions.

    <?php
    if ( has_post_thumbnail()) {
      $custom_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'YOUR-CUSTOM-THUMB');
    	echo '<a href="' . $custom_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" data-rel="lightbox" >'; the_post_thumbnail();
    	echo '</a>';
    }
    ?>

    Hope this helps people struggling with the same issue.

    #7316
    Bartosz
    Keymaster

    Sorry, I just found this thread. It was probably caoused by conditional loading. RL detects usage of images and galleries in post content ONLY. It can’t get through all you code and find if you used images anywhere else or not.

    So when you disabled conditional loading the RL code is being used on the page you had problems with.

    BTW: there’s a custom filter that allows you to have some extra control on the conditional loading feature – in case you’re interested it’s rl_lightbox_conditional_loading

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.