1

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>

2 Answers 2

2

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>
2
  • I've tried that and it doesn't work Feb 27, 2012 at 20:28
  • it doesn't work tells us almost nothing by which we can help you. do you have a lightbox script loaded? Feb 27, 2012 at 20:32
0

@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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