<\/a>/i'; preg_match_all( $string, $content, $matches, PREG_SET_ORDER); //Check which attachment is referenced foreach ($matches as $val) { $slimbox_caption = ''; $post = get_post($val[5]); $slimbox_caption = esc_attr( $post->post_content ); //Replace the instance with the lightbox and title(caption) references. Won't fail if caption is empty. $string = ''; $replace = ''; $content = str_replace( $string, $replace, $content); } return $content; } /* Filter Hook */ add_filter('the_content', 'add_rel_lightbox', 2); ?>