Post Thumbnail Lightbox
-
I am trying to create a lightbox to display the post thumbnail/featured image in a custom post type (the page link given is an example, the image in question is the first on the page). Using the following code I’m creating an attachment link which opens as you’d expect without the lightbox:
<?php if ( get_the_post_thumbnail($post_id) != '' ) { ?> <a href="<?php echo get_attachment_link( get_post_thumbnail_id() ); ?>"><?php the_post_thumbnail( 'Feed' ); ?></a> <?php } ?>I’m aware that SLB may require me to activate manually as per this article but despite managing to get this working on the gallery (lower down the page) I haven’t found a way to make this work here.
I’ll illustrate my logic, although it’s clearly wrong (this simply breaks the page):
<?php if ( get_the_post_thumbnail($post_id) != '' ) { ?> <?php $content = '<a href="<?php echo get_attachment_link( get_post_thumbnail_id() ); ?>"><?php the_post_thumbnail( 'Feed' ); ?></a>'; if ( function_exists('slb_activate') ) { $content = slb_activate($content); } echo $content; ?> <?php } ?>What should I be doing differently to get the full size featured image to open into a lightbox?
- This topic was modified 7 years, 4 months ago by .
- This topic was modified 7 years, 4 months ago by .
The page I need help with: [log in to see the link]
The topic ‘Post Thumbnail Lightbox’ is closed to new replies.