Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How do i add the light box function

rel="lightbox"

to the code below

<a href="<?php echo wp_get_attachment_url($post->ID); ?>" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>"><?php echo wp_get_attachment_image($post->ID, 'large' ); ?></a>
share|improve this question
add comment

2 Answers

@helgatheviking's solution is the correct one. If it doesn't work, then something else is wrong (e.g. is the lightbox script properly enqueued, etc.)

Alternatively, you can use this plugin: http://wordpress.org/extend/plugins/jquery-lightbox-balupton-edition/.

Or one of the few others in the WordPress plugin repository: http://wordpress.org/extend/plugins/tags/lightbox.

share|improve this answer
add comment

i think most lightbox plugins require the rel or class attribute to be on the link, so:

<a href="<?php echo wp_get_attachment_url($post->ID); ?>" rel="lightbox" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>"><?php echo wp_get_attachment_image($post->ID, 'large' ); ?></a>
share|improve this answer
    
I've tried that and it doesn't work –  Terrell Anderson Feb 27 '12 at 20:28
    
it doesn't work tells us almost nothing by which we can help you. do you have a lightbox script loaded? –  helgatheviking Feb 27 '12 at 20:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.