WordPress visual editor & HTML in posts
September 19, 2007As mentioned in my previous post I completely redesigned the downloads section on this site. I saw some nice examples on another blog and created a modified HTML version to achieve a similar effect. Once I was happy with both the HTML and the CSS I transfered the CSS to the stylesheet and the HTML into a post.
When I previewed the page I was shocked. The layout was totally different than what I had in mind. So I decided to check the source. It was than that I discovered something in WordPress has changed the original code to something totally different. This was why the layout was totally off.
I first suspected the wpautop function, which auto formats your posts in WordPress. After disabling this functionality the HTML got through as intended. However, it also left me with a lot of changes to earlier posts. I relied on the autoformat to get the job done.
Since disabling the function was not an option, I decided to dig a little deeper. It turns out that TinyMCE, the visual editor in WordPress, is programmed to replace tags it does not recognize. Sure enough, after disabling the Visual Editor in the Users panel and enabling the wpautop function, my blog returned to a normal state.
Older posts are displayed as usual, newer posts with HTML and CSS display also as intended. Three hours gone, problem solved.















