Folks, one of our users (thanks, Jake77!) dropped an email because he was having trouble with putting PHP code into one of the posts on his blog. When he described what was going on, and showed us the page that was broken, we saw the problem immediately, and I realized that there is another important plugin you need to have on your site if you are going to use IMC code in your posts.

Here is the problem: once you embed PHP code into your post or page, you must never, ever re-open the post in your editor in "Visual" mode. Now, the Exec-PHP plugin puts a warning at the top of the Edit Post/Page display to tell you about this, but it is still possible to miss what that warning is saying or not realize that it applies to you, and still make the mistake.

Here's what can happen. If you open your page or post for editing and then put the editor into "Visual" (aka WYSIWYG) mode, and then save it, WordPress will convert a lot of the characters in your PHP code into their equivalent "HTML entities". Those are the little codes you see if you look at the page source in your browser sometimes. They all start with an '&' character and end with a ';' character. They represent things like a "greater than" or "less than" sign, stuff like that. If this happens to those characters when they're part of some PHP code, the code will now be broken.

The good news is that there is a way to safely prevent yourself from accidentally messing up your code in this way. You just need to install the Deactivate Visual Editor WordPress plugin. It's totally free, and you can download it off of wordpress.org using that link.

Install it on your blog and activate it. Once you have done that, you can go in to any of your pages or posts that you've embedded IMC custom PHP code into and turn off the Visual editor mode completely for just that page or post. All you have to do is add a "Custom Field" to the page/post. The field name is "deactivate_visual_editor" and you should set the field value to "true". I've also posted a quick video here to demonstrate this for you.

The great thing about this plugin is that it lets you turn off the visual tab just on the pages and posts you need to in order to protect your embedded PHP code, but leave it on for your convenience on all the other pages and posts. If you have any questions, feel free to drop them in the comments field below or send us a note using the "Contact Us" page!

Thanks for joining us here at the IMC!

More posts filed under category: Tips and TricksWordPress Tools

Like this post? Subscribe to our RSS feed and get loads more!