Forums

[resolved] Custom Taxonomy and Lightbox (3 posts)

  1. Oscar
    Member
    Posted 6 months ago #

    My primary focus with WordPress is my photography. I created a custom taxonomy for my images.
    I was able to tag each photo and also create a custom tag page for the custom taxonomy that showcases the thumbnail of each photo based on the tag.
    My question is on the custom taxonomy page where the photos are outputted. I would like the images to open in lightbox and not to the attachment page for that particular image.

    Below is some of the code that is used in my custom taxonomy php page.

    This code outputs the thumbnails based on the custom tag. The thumbnails link to the attachment page. I would like to open the images in a lightbox. Adding rel="lightbox" opens the attachment page in a lightbox.

    <?php while (have_posts()): the_post(); ?>
    <a href='<?php the_permalink() ?>' title='<?php the_title(); ?>'><?php echo wp_get_attachment_image( '','thumbnail' ); ?></a>
    <?php endwhile; ?>

    Thanks for any help or helpful links in advance.

  2. Oscar
    Member
    Posted 6 months ago #

    Got it!

    <a href="<?php echo wp_get_attachment_url($image->ID); ?>" rel="lightbox"><?php echo wp_get_attachment_image( $image->ID, 'thumbnail' ); ?></a>

  3. Oscar
    Member
    Posted 6 months ago #

    Works great!

Reply

You must log in to post.

About this Topic