Last modified:

I found that I needed a plugin that would let me run Php code directly from a WordPress post. I was doing a long post and I just couldn’t take working in the WordPress editor any more. It is so tedious.

This takes a long time!

Here’s how it was going: Type in some stuff in the WordPress text editor for the post. Click Save Draft. Wait for the save. The lines previously typed in the WordPress editor all tabbed in and out of place randomly after the edit page reloads. Switch to the tab in the browser to go to the page where the Preview of the post is loaded. Click refresh. Check to see if what I typed in looks OK. Rinse and repeat. Over and over. Tedium is not a strong enough word.

Writing a post in WordPress is a difficult task. For simple blog posts, paragraphs of text and an image or two, things go OK. That’s probably what most WordPress users are doing.

But if you want to have any control of the page layout you are out of luck. And if you are trying to type in something like a multi level ol or ul (ordered or unordered list) you are plain out of luck.

I was keying in a long three level list and the ul’s and li’s just kept jumping all over the place. I was wishing I could use just a simple editor (like Notepad++) that I use a lot.

So I opened up Notepad++. Copied the text from the WordPress edit page to Notepad++. I continued typing in my list. This was going a lot faster because the text editor is made for code like this and keeps everything wonderfully lined up and indented. And it lets me know if I missed a closing tag somewhere or made some other typo.

So for about 4 minutes I was happy.

But then when I wanted to see what the stuff I had typed into Notepad++ looked like on my WordPress site, I had to copy the text from Notepad++ and paste it into the WordPress edit page. Then click Save Draft again, wait, wait, wait, you know how it goes. It drives a person crazy.

The Eureka Moment

Then it came to me. What if I could use some type of Include statement in the WordPress post where it would load in a second file like you can do with Php or Sass in CSS? And I found out I could do this if I used a plugin that allows native Php code in a WordPress post.

I installed the Exec-PHP Plugin (2nd one listed) on the site and entered the following line of code in my post and saved the post.

I opened up changelog.php in my text editor. Then made changes in an environment where it’s easy to type in text. Whenever I saved the file locally, my FTP watch program automatically uploaded it instantly to my server’s wp-content/includes/ folder.

All I had to do then was switch to my browser, hit F5 to refresh the page, and I could instantly see the changes. It is very slick!

Pros and Cons?
  • Pros:
    • You can type in your regular text or Html editor. The one you are familiar with.
    • Your post content is saved locally on your hard drive and then uploaded to your server. Instant Backup.
    • It is very fast. Save the file. Switch to the browser. Hit F5. And you see the results.
  • Cons:
    • If you only backup your WordPress database you might have a problem. If you make sure you keep your local files or also bacfk them up then you’ll be OK.
    • Possible increase in load time for the page. I, of course, couldn’t see any difference. If anything it sure eliminates a lot of database saving, retrieving and general thrashing.
2 Plugins You Can Try

I’m currently testing two diffent plugins that allow you to use Php code directly in a post. Both of them are very old. But I guess you could say that Php has been around for a long time as well. Both are free plugins so a big thank you to the authors.

They both work. I am testing them on two different blogs. However I won’t say I’ve done enough testing to make sure there are no problems with either one. So buyer beware as they say. So far, no problems. And I am tickled pink with how they work, especially for the things I want to use them for.

WordPress PHP Exec Plugin

The first one is the WordPress PHP Exec Plugin.

WordPress PHP Exec Plugin

You can get it at Priyadi’s Place » Blog Archive » WordPress PHP Exec Plugin.

Exec-PHP Plugin

The second one is the Bluesome Exec-PHP plugin for WordPress.

Bluesome Exec-PHP plugin

And you can download it here: Bluesome | Exec-PHP plugin for WordPress

You might want to give this a try. It makes writing and changing WordPress posts extremely easy. I just have to say it again: This is slick!

Leave a Comment