WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Building my first site. Running v3.1.1 with the Boldy theme from Site5.

Boldy makes use of prettyPhoto Lightbox. If you refer to the instructions for setting up Boldy (bottom of page)

For adding Lightbox behaviour to a link just add rel="prettyPhoto" to the image Link Rel enter image description here

I have just imported about 100 blog posts from Wordpress.com.

2 questions (although very related:

  1. How do I batch update all previous pictures to load by default with the prettyPhoto i.e. Apply a 'prettyphoto' tag to each pictures rel.

  2. I have about 15 authors for the blog. I know they will forget to manually set this prettyPhoto tag = Is there a way to make it default to this?

share|improve this question
up vote 3 down vote accepted

You can create a content_filter that will update on the fly meaning that you don't have to update all previous pictures and it will be the default so you don't have to worry about your authors. something like this:

function autoadd_rel_prettyPhoto($content) {
    global $post;
    $pattern        = "/(<a(?![^>]*?rel=['\"]prettyPhoto.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
    $replacement    = '$1 rel="prettyPhoto['.$post->ID.']">';
    $content = preg_replace($pattern, $replacement, $content);
    return $content;

share|improve this answer
sounds perfect. Im a noob. Where do I paste this function into? The functions.php? I assume it does not matter where in that file? – Simon Apr 15 '11 at 4:43
yeah, that function needs to be added to your functions.php file – Piet Apr 15 '11 at 4:46
Sorry did'nt see your comment, yes just copy this code and paste it anywhere in your theme's functions.php file. – Bainternet Apr 15 '11 at 5:47
Can someone help me out. I added this function to my functions.php file of my theme. But the link rel is not applied for images. – Ian Nov 15 '12 at 16:27

Your Answer


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.