Subscribe

How to Stop Wordpress Messing With Your Code!

11/12/2009 | By Clement Yeung
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Every designer that creates templates for Wordpress will undoubtedly run into the brick wall that is “Wordpress autoformatting”.

To cut a long story short, it is possible to input HTML code into any post or page created through the Wordpress interface. However, Wordpress often decides to reconstitute your code into meaningless crap.

If we want to stop this, we need to disable the “filters” that Wordpress uses to format the user-inputted content. These filters’ functions are located in the “functions.php” file in the root directory of the theme.

A quick but mindless way of getting rid of the auto-formatting would be to comment-out the offending functions; “wpautop” and “wptexturize”…

A more thoughtful way of removing them is to watch this video:

More Articles By Clement Yeung

Author: Clement Yeung

Clement is a business owner, entrepreneur, health freak, human & animal rights activist and a joker. He founded easisell.com in late 2007, a creative marketing & design business that continues to go from strength to strength. "Most of the marketing on the web today is garbage" Clement says. "All it ends up doing is wasting money and time. Clients get much better, faster results when they focus on the 20% that really matters." If you have an internet-based business and you want to get better exposure, contact clement@easisell.com for a no-obligation, no-fee evaluation. Alternatively, you can catch him on Twitter (@clementyeung).


10 Comments

Hugh Collier

November 13th, 2009

Hi Clement. This is a nice solution to the problem of Wordpress messing with html imputed in through the back-end. I’m sure I’ll find a use for this in one of my projects soon. Thanks for bringing it to our attention.

[Reply]

Clement Yeung

November 13th, 2009

I just realized that I didn’t edit that video. How embarassing!

I’ll have to reupload this now < :D

[Reply]

Hugh Collier

November 13th, 2009

Lol! Not to worry. I thought you’d left the multiple endings in deliberately as out-takes from the recording. :)

I’m currently recording a few screencasts for a blog I’m launching soon and I’m forever starting over when I mess up. I actually hadn’t thought to just start the sentence over and edit it afterwards. (dumb I know!)

[Reply]

Clement Yeung

November 13th, 2009

Hahaha :D It took me a while to figure it out too, I guess that’s what happens with chronic perfectionism <

[Reply]

Christopher West

November 18th, 2009

Nice one Clement. I used Wordpress alot and havnt come up with this issue that much. but thanks for the info

[Reply]

Nile

November 20th, 2009

This is only effective is the layout already has these functions, meaning the user designed their theme with these functions, or it was something already built in if it was a theme that was free and available for download.

[Reply]

Clement Yeung

November 20th, 2009

That’s very true, this ONLY works if the theme you’re using has the WPAUTOP and WPTEXTURIZE functions already declared.

Thematic by @iandstewart is a theme that has all that and more.

Thanks for the heads-up Nile.

[Reply]

Todd Wallace

November 21st, 2009

This may come in handy. I’ve been having issues with a non-breaking space that I’m forcing in. WP keeps removing it unless I stand on one leg, jump up and down, hold my left ear with my right hand, and moo like a duck.

Thanks for the heads-up.

[Reply]

Jeremy Reply:

Yup, having ta similar Wordpress issue right now where I go in and add several breaks in the code, and when it posts, content is still right-on-top of the other text I want it separated from.
Although I don’t set up the templates on our site, I’m definitely forwarding this to the guy that does.

[Reply]

Cynthia Lay

December 28th, 2009

Clement, this is fabulous! You have saved me SO many headaches… yippeee!

xoxo
Cynthia

[Reply]

Leave a Reply

Anti-Spam Protection by WP-SpamFree

Related Posts

Check out some more great tutorials and articles that you might like.