Remove rel=”attachment wp-att-XX”

When you add an image with “Add media” to the WYSIWYG editor the link around the image automatically gets a rel=”attachment wp-att-XX”. I would like to remove this with a script – Can anyone help me? 🙂

2 Answers
2

You can remove it right before post is printed to the screen by stripping it out from content. But remember it still will meddle in Editor.

<?php
function my_remove_rel_attr($content) {
    return preg_replace('/\s+rel="attachment wp-att-[0-9]+"/i', '', $content);
}
add_filter('the_content', 'my_remove_rel_attr');

Leave a Comment