How to to stop html editor from addig <p> tags to shortcodes, images, etc
-
03-11-2019 - |
Pregunta
I know this this is covered as individual topics but What I am looking for is a single function that stops <p>
tags from being wrapped around via the Wordpress editor to shortcodes and images and also removes empty <p>
tages, for example:
- remove
<p>
tags that get wrapped around shortcodes, i.e.,<p>[shortcode]</p>
- remove empty
<p></p>
tags - remove
<p>
tags with whitespace, i.e.,<p> </p>
or<p> </p>
etc. - remove
<p>
tags that get wrapped around<img>
tags, i.e.,<p><img blabla /></p>
I have been using a few different functions that take $content
and strips out the <p>
tags via preg_replace()
but I can not figure out how to get all four requirements to work in a single function.
Its seems like too much overhead to run $content
through four different functions before $content
is displayed.
Also can you recommend a good source to learn how to use all the agreements for preg_replace()?
No hay solución correcta
Licenciado bajo: CC-BY-SA con atribución
No afiliado a wordpress.stackexchange