i am trying to remove p tag from wordpress that automatically adds p tag in images.Also i center the images with wordpress so it becomes something like this
so i tried adding this code
function filter_ptags_on_images($content){
return preg_replace('/<p style=".*?">s*(<a .*>)?s*(<img .* />)s*(</a>)?s*</p>/iU', '123', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
This removes style from p tag and it become something like this
<p><img src=...><p>
Can anyone help me how to remove p from images only.
Try below code:
Or try to modify your own code:
using this hack you had remove P tag from your content please use this hack and let me know once this work fine.