Disable automatic p and br tags in the wordpress editor – and do it as early, as you can!
Why you should disable them as early, as you can
I don’t like visual HTML-editors, because they always mess up your HTML. So the first thing, that I’ve done in my wordpress-profile, was checking the check-box
Disable the visual editor when writing.
But today I found out, that this is worth nothing.
Even when in text-mode, wordpress is adding some
<br>-tags automagically and, hence, is automagically messing up my neatly hand-crafted HTML-code.
Fuck wordpress! (Ehem – sorry for that outburst)…
But what is even worse: after really turning off wordpress’s automagically-messup-functionality, nearly all my handwritten
<p>-tags were gone, too.
So, if you want to turn of automatic
<br>-tags, you should really do it as early, as you can. Otherwise, you will have to clean up all your old posts afterwards like me. TI’ve lost some hours with usless HTML-editing today, because of that sh#%&*!
How to disable them
The wordpress-documentation of the build-in HTML-editor links to this post, which describs how to disable autmatic use of paragraph tags.
Simple open the file
wp-includes/default-filters.php of you wordpress-installation and comment out the following line:
If you are building your own wordpress-theme – like me – you alternatively can add the following to the
functions.php-file of your theme:
Why you should disable automatic paragraph tags
For example, I was wondering a while, where all that whitespace in my posts were coming from.
Being used to handcraft my HTML, I often wrote one sentence per line, or put some empty lines inbetween to clearly arange my code.
There comes wordpress, messing everything up by automagically putting every sentence in its own paragraph, because it was written on its own line and putting
<br> inbetween, to reflect my empty lines.
But even worse, wordpress also puts these unwanted
<p>-tags arround HTML-code, that breaks because of it.
For example, I eventually found out about this auto-messup functionallity, because I was checking my blog-post with a html-validator and was wondering, why the validator was grumping about a
<quote>-tag inside flow content, which I’ve never put there. It turned out, that wordpress had put it there for me…
Hey thank you for Guidence. I am also messing around with same problem but unfortunately i searched every post on google regarding this.
I applied all the methods like
But nothing worked. Whenever i go to post code editor and embed my beautiful Code and as soon as i click on preview button. Those Nasty cranky tags [ } appear from somewhere.
How ever when i cleared all the spaces of my code. It worked but it makes it hard to debug code and adding new lines of code.
Please reply as soon as possible SIR !