I'm using the multiEdit plugin to create some content regions on a template.
One of those region is for some photos that are going to be using jQuery cycle to rotate through the images.
But, as usual, Wordpress (or the editor rather) is wrapping all of the images in a <p>
tag.
I've used the functions hack from CSS-Tricks to remove the <p>
tags from the content:
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
But, from what I can tell, it only looks for the_content
and not for anything else.
Multiedit uses this: <?php multieditDisplay('name_of_region'); ?>
to display the content block in the template.
So, I tried to change the function to this:
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('multieditDisplay', 'filter_ptags_on_images');
But no such luck.
So, I'm not so sure if I'm missing something or just going about it the wrong way.
Ok, well I found a workaround.
I did a write up about it here:
http://ultraloveninja.roon.io/filtering-paragraph-tags-with-the-wordpress-multiedit-plugin