I'm trying to strip all images and the surrounding <a>
tag from get_the_content()
with this piece of code:
<?php
$content = get_the_content();
$postOutput = preg_replace(array('{<a[^>]*><img[^>]+.}','{></a>}'),'', $content);
echo $postOutput;
?>
That works fine, except there are no <p>
tags around the paragraphs.
1. Is this normal when using get_the_content()
?
2. and how could I add them to my result?
3. Or is my regex wrong?
Okay I will answer my own questions:
<p>
onget_the_content()
thanks @s_ha_dum<p>
I need to apply the content filter as mentioned here (scroll down to "Alternative Usage").See the new question that lead to the following code here