Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Adding rel="prettyPhoto" into gallery shortcode WordPress


Hello all,
I need exactly what the title says: to add the rel="prettyPhoto" attribute into the gallery output via functions.php. This way I can take advantage of the lightbox feature I already have, without using a plugin.

Answers (1)


Utkarsh Kukreti answers:

add_filter( 'wp_get_attachment_link', 'gallery_prettyPhoto');

function gallery_prettyPhoto ($content) {
// add checks if you want to add prettyPhoto on certain places (archives etc).
return str_replace("<a", "<a rel='prettyPhoto'", $content);