I have this code in my webpage...
<p style="text-align: center;">
<a href="http://***.com/wp-content/uploads/2012/01/18169921.jpg">
<img class="size-full wp-image-426 aligncenter" title="1816992" src="http://***.com/wp-content/uploads/2012/01/18169921.jpg" alt="" width="600" height="300">
</a>
</p>
and I want it to be something like this. Replace p tag with div.
<div class="someclass">
<a href="http://***.com/wp-content/uploads/2012/01/18169921.jpg">
<img class="size-full wp-image-426 aligncenter" title="1816992" src="http://***.com/wp-content/uploads/2012/01/18169921.jpg" alt="" width="600" height="300">
</a>
</div>
I have removed the <p> from the code using preg_replace() but not able to get how to add <div class="someclass"> in it while replacing the <p>.
Here is the code I have used. Plz help me to add div tag with some class.
function remove_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', 'remove_ptags_on_images');