Home Wordpress blockquote removes `<br>` tag
Reply: 0

Wordpress blockquote removes `<br>` tag

Interactive Published in 2018-02-14 09:59:38Z

So I have a quote in my page template and I would like to give the user the opportunity to add line breaks whenever they desire to do so.

I wanted the blockquote to have an extra <p> tag inside the <blockquote> tag so I could style it better.

The problem I'm having now is that the <br /> tags are being removed. While using the wpautop() function they should stay.

Here is what I did:

$matched = preg_match("~(?<=<blockquote>)([\s\S]+?)(?=</blockquote>)~",
$child->post_content, $found); // find the quote in the content with regEx

$found = current($found);
$replace   = "<blockquote><p>".$found."</p></blockquote>";// add the <p> tag
$newphrase = str_replace($found, $replace, $found);

$clearQuote = preg_replace("~<blockquote>([\s\S]+?)</blockquote>~", '', 
wpautop($child->post_content, true)); // use wpautop to keep the <p> tag

Can anyone see why the <br> tag is being removed or do I need to add something else?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.379875 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO