Creating a child tag in WordPress content

I have the following code which pulls out blockquote information from WordPress post content

HTML

Read More
<?php
        // get the content
        $block = get_the_content();

        // check and retrieve blockquote
        if(preg_match('~<blockquote>([sS]+?)</blockquote>~', $block, $matches))

        // output blockquote
        echo '<blockquote>'.$matches[1].'</blockquote>';
?>  

This outputs the blockquote information in the following way

<blockquote>
    The text from the blockquote inside the post.
</blockquote>

I need the the output to be this …

<blockquote>
   <p> The text from the blockquote inside the post. </p>
</blockquote>  

I can’t figure out how to accomplish this

Related posts

1 comment

  1. Replace

    echo '<blockquote>'.$matches[1].'</blockquote>';
    

    with this

    echo '<blockquote><p>'.$matches[1].'</p></blockquote>';
    

Comments are closed.