Wordpress PHP Execution Plugin

The PHP Execution Plugin is a Wordpress plugin which allows users to write php code inside of their posts and pages. Embedded php code will be executed when the post is shown. In doing so, the plugin offers the possibility to utilize dynamic content inside of posts.

Probably you might say, that there are already plugins that do the same!
So why another plugin that executes php code?

Well this plugin integrates well with Wordpress’ visual editor as the picture above shows. So in contrast to other plugins, you don’t need to turn off the visual editor in order to edit your php code.


With this plugin installed, you can insert php code into your post in html view and switch to visual view without losing or destroying the code:

This is how the php code above looks in the visual editor:

You can even drag and drop your code snippets around:

The executed php code inside the post will look like this:


This plugin is installed like any other Wordpress plugin:

  • Download the latest version of the plugin.
  • Unzip it into the /wp-content/plugins/ folder of your Wordpress installation resulting in a /wp-content/plugins/php_execution/ folder.
  • Login as administrator and activate the plugin.
  • Wordpress’ tag balancing has to be turned off. This is true by default. If you have enabled tag balancing, turn it off again by unchecking “WordPress should correct invalidly nested XHTML automatically” in Settings»Writing of the admin section.
  • Optionally set PHP execution permissions in the Settings»PHP Execution panel. By default all administrators possess the permission to execute php code.
  • As javascript code is added to the editor, you have to clear your browser cache !!! Otherwise the plugin won’t work as the code added by it simply won’t get executed. For information on how to clear the browser cache, follow this link.

For information on how to install Wordpress plugins in general follow this link.


  • WordPress 2.5 or higher
  • PHP Execution is compatible with WordPress MU, as long as you install it in conjunction with another plugin called Unfiltered MU (http://wordpress.org/extend/plugins/unfiltered-mu/). See the comments below written by Ray for further information.

tested on WordPress 2.5, 2.6, 2.7 & 2.8 with IE 6 & 7, Firefox 3


Editing PHP

  • php code can be edited in the html view of the editor.
  • php code is embedded into a post in the same way as in any other html page: a php block begins with <?php and ends with ?>. The short open tag, i.e. <?, is not supported.
  • One restriction is, that you are not allowed to use the ending delimeter (?>) somewhere inside a string in your php code block. If you do so, this ending delimeter will be matched and your code will inevitably break apart. So don’t write e.g.:
    some text
    <?php $test = "hello ?>"  ?>
    more text

    Writing $test = "hello ?&gt;" instead will not lead to any problems.

  • Php code is not executed in the global scope. If you need to gain access to variables in the global scope you need to “import” them first with global $var1, $var2;.
  • This plugin does not evaluate every single code snippet, but the content of the post as a whole. So the following lines won’t result in errors:
    <?php if ($test==true) { ?>
    The test was successful.
    <?php } else { ?>
    The test failed.
    <?php } ?>
  • When switching between html and visual view the php code is not altered in any case. All html tags, whitespaces etc. in your code are preserved.

Admin Section: setting permissions for code execution

As executing php code is a sensitive task and possible exploitation should be prevented for security reasons, the PHP Execution Plugin provides an administration panel (Settings»PHP Execution) where you can grant or deny php execution permissions to certain Wordpress roles in general or set explicit permissions for specific users.

The plugin also automatically prevents users with no php execution rights from editing posts or pages of users with these rights. It thus fixes a possible security leak where people without php execution rights can still execute code with editing other users’ posts.


  • Internationalization


Creative Commons GNU GPL 2.0


php_execution.zip (version 1.0.1 – 2009/08/07)
browse the contents of php_execution.zip

This entry was posted on Wednesday, February 25th, 2009 at 21:50. It is filed under php and tagged with , , , , , , . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Marsha - March 10th, 2009 at 8:49 pm

I have installed this PHP Execution plugin but it’s not working. I have followed the instructions and gone over it several times and still nothing works. I tried it on 2 different WP blogs with the same results. I have tried to use your test code and that won’t even work.

The first site I tried it on only has a couple of basic plugins installed so I know it’s not a compatibility issue. it just won’t work. It does absolutely nothing.

The php code gets stripped out immediately just like it did before I installed your plugin. And yes I made sure to uncheck “WordPress should correct invalidly nested XHTML automatically”.

Is there something you can suggest to get it working?

nik - March 10th, 2009 at 9:18 pm

Could you tell me, which version of WordPress you are using, because all php editing possibilities utterly depend on the javascript of WordPress’ text editor? Only WordPress since version 2.5 is supported.

I have checked the installation routine another time and detected that you need to clear your browser cache in order to make the plugin work. As the plugin adds javascript code to the editor and WordPress tries to cache javascript, the plugin’s javascript code only gets executed, when the cache was cleared.
I have added a few lines to the installation instructions above.

Top work - March 16th, 2009 at 8:16 pm

Top work…

Excellent, just gotta recomend this….

Efox - March 17th, 2009 at 8:13 pm

Marsha, I was having this problem, the path of the plug-in was not named php_execution (was php-execution-plugin) because I installed it through the Wordpress admin, not by the ftp. Renaming the path and clearing the browser cache again solved here. Great plug-in!

P.S. Sorry for the poor english writing, I’m brazilian! ;)

Kai - March 26th, 2009 at 1:12 am

Works like a charm, just exactly what I have been looking for! +1 for you bud

PS: sweet theme, inspired me to create something similar now…

prof1 - April 8th, 2009 at 2:19 pm

Wordpress allows for the plugins directory to be moved from the default location (define( ‘WP_PLUGIN_DIR’…)). See wp-settings.php. In this case the PHP_EXECUTION_BASE_URL constant works incorrectly

Manet - April 18th, 2009 at 9:08 am

It works. However, i can only use it in HTML mode. When I switch to Visual Editor mode it destroyed my php code.
I am using WP2.7.1.

Any idea? did I do anything wrong? though installation is very straight forward.

Scotsman Ice Machine - April 21st, 2009 at 1:04 pm

I was searching for the PHP execution plugin for quite a long time and I’m glad that I have found it. I have installed it and if any problems I would ask for help. Thanks a lot for this plugin.

Lipe - April 22nd, 2009 at 3:52 pm

Same as Manet here, works in HTML mode but when i switch to Visual the code desappears. Using 2.7.1 just like him. : (

Lipe - April 22nd, 2009 at 4:52 pm

Solved. Same as Efox, renamed the folder to php_execution. Was renamed to php-execution and not _. You should name it correcly in the official ZIP. Congrats for the great work ! Cya

Craig - April 24th, 2009 at 12:50 pm

I am trying to add kaizentrack Tracking JS code.


When I enter the code in editor I should enter in html view?? I can’t add via visual as code shows up on live page.

and I need to clear cache on each page prior to inserting code?

Am I right?

Craig - April 24th, 2009 at 12:51 pm

Code disappeared i will try again


Tony @ Sports Betting Picks - April 25th, 2009 at 7:54 pm

Thanks for this great plugin.

Works like champ.


Andy Beard - April 26th, 2009 at 6:35 pm

The best way to add javascript using this plugin (at least until it has a javascript sister) would be to echo it using PHP.

Tom - May 1st, 2009 at 5:38 am

Is a search engine going to see the resulting output as a java script (unreadable) or as php output (readable)? I cant figure that from the description… Thanks!

WordPress Split-testing Google Website Optimizer - May 9th, 2009 at 12:51 pm

[...] PHP plugin I discovered rocks – I tweeted about it a couple of weeks [...]

Ray - May 13th, 2009 at 2:48 am

Hi Nicolas,

For your variable, “‘PHP_EXECUTION_BASE_URL”, please use the variable WP_CONTENT_URL or WP_PLUGIN_URL instead of a hard-coded “wp-content” to get the correct plugin path.

The reason I bring this up is because I am using a custom ‘wp-content’ directory.

Thanks for reading,

Ray - May 13th, 2009 at 2:53 am

One other thing,

I downloaded your plugin from the Wordpress Plugin repository and the PHP_EXECUTION_BASE_URL is incorrect.

Instead of “php-execution-plugin” as the directory name, your php script has “php_execution” as the directory name.

Just a heads up!

nik - May 14th, 2009 at 9:00 pm

Hello Ray,

i have fixed the two bugs you mentioned. The plugin now accounts for a custom WP_PLUGIN or WP_CONTENT directory, as well as for custom plugin folder names like “php_execution” or “php-execution-plugin”.

In either way it should work right now.

But as always: For the changes to take effect, the browser cache needs to be cleared.

Jacob Share - May 18th, 2009 at 9:59 am

Is this plugin supposed to be compatible with WPMU?

Andrea - May 20th, 2009 at 4:20 pm

There is something wrong.

Sometimes the code is translated in HTML, sometimes it just disappears after saving the contents.

In any case, doesn’t seems to work to me.

- WP 2.7.x
- “WordPress should correct invalidly nested XHTML automatically”: never enabled
- Cache cleared
- Plugin just downloaded

I give up: I’ll look for something working.

nik - May 20th, 2009 at 5:42 pm

Actually i haven’t tested the compatibility to WPMU yet. But as 99% of the code of WPMU is congurent to WP there probably are no issues. I’ll add another comment, when i have tested it. But in general, if you offer WP as a service to the outside world, i doubt that it is a good idea to grant php execution permissions.

What you describe is the “normal” PHP editing behavior of TinyMCE. You probably have missed to install the plugin properly (either installation itself or cache clearing).

Martin Redfern - May 27th, 2009 at 11:03 pm

Absolutely fantastic plugin.
I have been banging my head against several other PHP execution plugins for hours, all of which execute each code snippet as if it stands alone … grrr … and then I finally find this thorough piece of work which not only executes the whole page in one go, thus allowing multi-line PHP wrapped around HTML, but also permits continued use of the WYSIWYG editor in the most delightful way!
Many thanks and keep up the good work.

best4future - June 5th, 2009 at 2:15 am

Thanks a great for your help! The plug in works beautifully!! Thank you very much!!

I have one more question, forgiving my devotion to small details: can I list the links according to the website titles, not the author names? The default display all links and order list by Name in ASCENDING…

Again, thank you very much for your wonderful plug in!!

百年孤独(Nicholas) - June 14th, 2009 at 1:25 pm

Not compatible with WP 2.8 ? I found WP 2.8 would replace <?php to < ?php automatically. Hope this problem would be fixed.

nik - June 15th, 2009 at 1:06 pm

Just checked the plugin with WP 2.8. It is working without any problems.

There were no sensitive changes in WP 2.8 that affect the functionality of PHP Execution.
The most important file for the functionality of the plugin (wp-admin/js/editor.js) was not altered severely.

Perhaps you forgot to clear the browser cache or there is a conflict with another plugin you have installed.

kurt - June 17th, 2009 at 4:44 pm

I’m unable to get an include statement to work. I’ve tried modifying the statement in every way – single quotes, double quotes, with/without prarentheses, etc. Print statements work so I know PHP code is executing.

Is there any reason why an include statement won’t work with this plugin?


kurt - June 17th, 2009 at 10:28 pm

After further testing, I’ve determined it has something to do with the host or possibly the php.ini file. I’m able to use this plugin on a site hosted by Bluehost. It doesn’t work on a site hosted on 1&1.

Any ideas would be aprreciated.


nik - June 18th, 2009 at 12:42 pm

it is hard to tell with so little information. What does “it does not work mean”? Are there any errors thrown by php and if so what is their content? Settings in the php.ini could possibly be the cause, but what are the differences between the settings on bluehost and 1&1. Is there any link to a phpinfo() file where one can check the settings?

Hikari - June 29th, 2009 at 5:03 am

Interesting. In my blog I can’t add php directly on the editor, it always split <?php to < ?php. So I need to go to phpMyAdmin and fix it, then always when I have to edit a post I must avoid Wordpress editor and go to phpMyAdmin.

I always used PHP-Exec to add PHP to posts. Is your plugin compatible with it? If I disable it and enable your plugin, will all old posts keep working?

nik - June 29th, 2009 at 11:29 am

PHP Execution will be compatible to every other plugin that stores php code in the database with the usual < ?php ... ?> tags. As far as i know these are:

PHP Execution is not compatible to:

This plugin keeps php code inside html tags in the database and parses these tags on every page request before evaluating the php code. This also leeds to unnecessary overhead.

Michael J - June 30th, 2009 at 11:40 pm

Excellent plugin! Thank you.

AM - July 1st, 2009 at 3:45 pm

Wonderful plugin. However, I’m trying to use the $_SERVER['REMOTE_ADDR'] superglobal within the php code in a post, and because Wordpress is executing the code, it’s using my webservers IP address instead of the visitors IP.

Any ideas how to get round this? Basically I’m trying to geo-localize the post based on the users IP….

karl - July 5th, 2009 at 6:04 pm


I have found an unfortunate bug in this plugin. When php is embedded in another tag (such as ‘<a href="" id="post-">‘), the WYSIWYG editor destroys the php code!

Perhaps my example will work with escaped tags:
<a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>">

Aaaand another bug:
If wordpress autosaves a draft while the WYSIWYG view is open, all php is turned into image tags and lost.

nik - July 7th, 2009 at 1:42 pm

Does the superglobal $_SERVER[REMOTE_ADDR] really only differ when executing PHP Code with this plugin??? Or is your webserver’s IP also printed when you put an "echo $_SERVER[REMOTE_ADDR]" statement hardcoded "in the loop" of wordpress.

Writing PHP Code inside of tags is not possbile with this plugin. This is not a bug, but owed to the basic functionality of the plugin as PHP Code is encoded to an image tag in the WYSIWYG editor. If this image tag is surrounded by other html tags and the result is no valid html, TinyMCE strips it out.

A working example for your code would be:
<?php echo '<a href="' . the_permalink() . '" id="post-'. the_ID() . '" >'; ?>

Now the PHP code is not inside of a html tag, but echos a valid html tag.

On your last question: The functionality of this plugin is to turn PHP Code into image tags when switching between source and WYSIWG view of the editor. That’s the basic functionality to retain and not loose the code. But i will have a look on the autosave functionality of drafts. Perhaps there are some differences when posts are saved via ajax requests which is the case for drafts. I personally have turned drafts off in my installation of wp as drafts are cluttering up the database.

Ray - July 7th, 2009 at 10:24 pm

Hi Nicolas,

I tested your plugin with WPMU 2.7.1 on my localbox and it doesn’t seem to work.

It activates fine, but PHP code gets stripped from the post.

Ray - July 7th, 2009 at 10:48 pm

Hi Nicolas,

Just an update.
Your plugin does work on WPMU.

WPMU adds a layer of security that filters out posts.

Downloading a plugin called “Unfiltered MU” will fix this problem for admins and editors.

nik - July 8th, 2009 at 10:12 am

Thanks a lot for sharing this info !!!

Kurt Schlatzer - July 16th, 2009 at 8:46 pm

While trying to figure out why your plugin would not work I discovered that if the “WordPress should correct invalidly nested XHTML automatically” is checked under the Writing settings in WP admin, the editor will convert <?php to < ?php (note the extra space before the ?).

Once I unchecked that option, your plugin worked.

Aleksey - July 21st, 2009 at 3:34 pm

Got “<?php to < ?php" problem on category and archive pages. :(
It works fine only on article page.

WP 2.8.2.
Tried "Unfiltered MU"and “WordPress should correct invalidly nested XHTML automatically" with no effect.

john - August 2nd, 2009 at 8:48 pm

Hey Ya i also tried it with wordpress mu 2.8.2 with the “Unfiltered MU” plugin and it still removed the php tags

Paul - August 6th, 2009 at 7:35 pm

I’ve really been enjoying your plugin. I have one problem. When I sign in on the http:/website/wordpress/wp-admin login I get this error message: Fatal error: Call to a member function on a non-object in /hsphere/local/home/my client’s site/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php on line 99

The error is in the initing object with wp settings section and the code line is: $this->current_user_can_exec_php = $current_user->has_cap(PHP_EXECUTION_CAPABILITY);

Any idea what is going on?

Richard - August 7th, 2009 at 11:46 am

Trying to use this plugin build and process forms (in Pages, not Posts). The $_POST global appears to always be empty even if form fields are filled in. Is there something about WordPress I’m missing? $_REQUEST has values from $_GET, but not $_POST.

Can someone point me at a solution?

nik - August 7th, 2009 at 6:27 pm

Even if i don’t know why the $current_user object does not already exist in your case, if have added a bugfix that fixes this problem. Version 1.0.1 is now available both from the wordpress plugin repository and this site.

I think that your problem is not plugin specific but rather a more general one.

Paul - August 10th, 2009 at 8:13 pm

Thanks for your response. I downloaded and installed 1.0.1 and got the same message. Also, in the list of plugins it is listed as Version 1.0.0 | By Nicolas Zeh. So I am not sure if the version number was not updated or I downloaded the wrong verson. What do you think? Do you need any particular info from me?

seo guru - August 11th, 2009 at 7:52 am

wow. Great plugin. Very handly tool. Big Thumb Up :)

Mark - August 18th, 2009 at 9:17 pm


I tried your sample code that you used here: http://screencast.com/t/GVZsv43Q, but the test if statement is failing. Im running wp 2.8.4. Any ideas?

Mark - August 18th, 2009 at 9:44 pm


nevermind, im retarded

Mark - August 18th, 2009 at 10:04 pm

Simple things like this dont work though. Result is showing null:

Mark - August 18th, 2009 at 10:06 pm

I apologize for all the comments, wish i could edit them. Since i cant post php, here is a image of the code

nik - August 19th, 2009 at 4:32 pm

This plugin uses PHP to evaluate PHP. So in almost all cases when the result is erroneous, it is not a bug in the plugin but an error in the php code, that was added to a post.

In your case it is not even an error, but only an unexpected result.
A little explanation to your code:

function execute_php()
   $package = 'test';
   global $package;


In the first line you create a variable named $package in the local (i.e. function) scope and assign the string "test" to it.
In the second line you “import” a variable named $package from the global scope to the local scope. This means that the value of the variable $package in the global scope is assigned to the variable $package in the local scope. It overwrites the local value.
As the variable $package is obviously not defined in the global scope, the var_dump statement in line 3 prints NULL.

Brad - September 3rd, 2009 at 4:01 pm

@nik: Thank you for providing this plugin. I’m eager to use it, but can’t seem to get it working.

The plugin is installed, and the PHP icons appear in the visual editor when I use your provided example. The issue is the php code isn’t being executed but simply echoed to the browser. The whole script is viewable in the html source. Does something need to be configured in my php configuration perhaps? I’ve verified “allow_url_fopen = On” in the php.ini file.

I’m using php5, apache2 with WP 2.8.4


nik - September 3rd, 2009 at 4:51 pm

The plugin uses PHP’s eval function to evaluate the PHP code inside of posts. Somehow this function is not executed properly on your host. This can be due to:

  • the eval function being disabled. But i don’t know if this is really possible within the php.ini
  • the php opening tags being escaped in some way. This can easily be checked in the html source of your post. The php opening tag has to look like <?php and not like <? php (blank space) or <\?php etc.

And make sure the option “WordPress should correct invalidly nested XHTML automatically” is not enabled in your WP settings. The PHP ini option “allow_url_fopen” is not needed by the plugin.

Brad - September 3rd, 2009 at 6:11 pm


Thanks for the quick reply. I’ve confirmed that the “WordPress should correct invalidly nested XHTML automatically” is unchecked in the WP -> Writing settings.

The code snippet I’m using is a cut & paste of your example in the documentation.

The test was successful.

The test failed.

I’m uncertain where eval might be disabled. Nothing stands out in php.ini. Any ideas would be most welcome. Thanks.

Greg - September 10th, 2009 at 7:33 pm

Hey there,

Cool plug-in! The main thing I want to use it for is accessing WP’s own PHP functions within a page.

After activating your plug-in, the following works just fine:

However, what I’d REALLY like to do is use the bloginfo function so that my base URL can be updated dynamically without breaking a javascript demo I have. The code in theory would look like this:

<script src="/demo/myscript.js">

If I replace only the PHP closing tag with the &gt thang, it still gets messed up. I assume it's to do with all the other tags I have in that soup, but I'm not sure how to resolve so that I can dynamically point to myscript.js.

Any ideas? Is it even possible? Making a separate template that uses the PHP is not in the cards.

Greg - September 10th, 2009 at 7:34 pm

bah, something messed up with my pre and code tags. Not sure if the original post is preserved in the back end… let me know if you need me to try again. ;-)

nik - September 10th, 2009 at 10:46 pm

Due to the missing code i don’t know if i get your problem right.
The plugin transfers the PHP code added in code view to an image tag when switching to wysiwyg view in the editor. So you can’t use PHP code in the html markup where an image tag would not be valid.

E.g.: The following will mess up:
<script src="<?php echo $BASE_URL; ?>/demo/myscript.js">

Instead you have to write it like this:
<?php echo '<script src="' . $BASE_URL . '/demo/myscript.js">'; ?>

In the second example the php code is NOT somewhere in the quotes of a script tag and therefore will result in a valid html image tag (<img src="..." />) when you switch to wysiwyg mode.
Hopefully that is the solution to the problem you are facing.

Ray - September 15th, 2009 at 3:34 am

Hey Nik, any plans on adding PHP functionality to widgets?

pixeline - September 21st, 2009 at 12:30 pm

VERY nice plugin! The only issue i have is, for it to work, the option “wordpress should fix xhtml tags” has to be turned off.
I believe it could be easily bypassed if you could set your plugin to use a custom tag (like [PHP] or or ).
All the trouble with the visual editor would easily be solved too.

thank you for sharing your work!


Pyr0S-9889 - October 6th, 2009 at 1:39 am

Funciona muy bien este complemento, eso sí, tengo que editar en modo HTML, pero no importa, me funciona con el path /wp-content/plugins/php-execution-plugin

This plugin works nice, and, i have to edit php code in HTML mode, by the way, works for me with /wp-content/plugins/php-execution-plugin path. Excuse my bad english

Yonatan - October 30th, 2009 at 9:09 am

Just what I’ve been looking for! Amazing! Thank you so much for this plugin.

Christian - November 9th, 2009 at 11:37 pm


really like the plugin but I’m having some problems unfortunately. I’ve written a plugin to display a gallery of images. The plugin provides a function to be called from the theme in order to print the html, style and javascript associated.

Now the problem is that the newline feeds in the plugin .php file seems to be interpreted and enclosed in p-tags. This botches the javascript. I’ve tried keeping all javascript on one singleline in the .php file and it seems to help somewhat but it’s not enough.

Anyone else had these problems?

I’ve made sure that the option for wordpress correcting xhtml is off, I’ve cleared the cache and I’m running WP 2.8.4.

monbouc - December 14th, 2009 at 4:14 am

Hi, just to mention.
I encountered the following bug on WP 2.8.6 : the editor role loses the “manage comments” capability. Or so does it seem (actually a plugin like Capability Manager still reads this capacity for this role, but the fact is that logged in as an editor in the admin section, the input checkbox to manage the comments are not printed and a message “You’re not allowed…” is given to any attempt to do so from the “moderate” link in the public pages).

Disabling PHP Execution solves the problem, but of course, this is not wished.
Any suggestion ?

PS : other troubled user http://wordpress.org/support/topic/335007#post-1293245

Ronni Plindstrup - December 21st, 2009 at 4:59 am


I have used your plugin – GREAT ONE!
However, after upgrading til WP 2.9, it mess up my frontpage. I have deactivated ALL my plugins and have avtivated one at a time. When I activate the PHP plugin, things goes wrong!

nik - December 21st, 2009 at 2:53 pm

The link you provided is refering to a different plugin called exec-php and not PHP Execution. That is probably why i cannot reproduce your problem.

PHP Execution is not compatible with Wordpress 2.9 yet.
I will have a look on it and post a new version of PHP Execution in January.

Mat Green - December 23rd, 2009 at 5:14 pm

Great Plugin right upto i had spent 5 hours coding combo boxes with specific data from categories and then I switch to visual mode to start formatting the page and it all goes!! I chose your plugin as you state it doesn’t disappear…… Have you fixed this??? using 2.9

Mat Green - December 23rd, 2009 at 5:17 pm

Is there anyway I can get my lost code back????

Alan Levine - January 4th, 2010 at 6:11 am

Thanks for the useful plugin; it appears to be working okay in my WP 2.9 blog. The one gotcha I just discovered is that it is trying to execute PHP code I use in posts to display using SyntaxHighlighterPlus plugin (http://thislab.com/2007/12/16/release-wordpress-plugin-syntaxhighlighter-plus/). It would be useful if there was a way to disable PHP Execution per post or code block, or if it ignored code inside the SyntaxHighlighterPlus shortcodes.

My current end around has been changing the author on posts with embedded code for display to a non admin author.

PS your captcha is not working.

KP - January 8th, 2010 at 7:37 pm

Editor(editor role) can not edit posts after activation of the plugin. Bug- Please fix it

Jeremy - January 14th, 2010 at 8:26 pm

Thanks for this, exactly what I needed!

I was having trouble until I put it within the tags in the HTML editor, in case that helps anyone out.

Jeremy - January 14th, 2010 at 8:27 pm

Sorry for my above – I meant to write the tags.

Jeremy - January 14th, 2010 at 8:28 pm

Crikey! Nik, sorry for bombarding your comments.

Once I put the PHP inside the “code” tags in the HTML editor, everything worked great.

Casey - January 17th, 2010 at 7:31 am

How is the updated for 2.9 coming.
I have tried it on a page entry and the php icon shows up in the view, but when I load the page there is no result. I am just trying a simple hello world.

Brent - January 28th, 2010 at 10:54 pm

Great plugin. Everything was working very well and still is aside from one caveat. I have a require_once in each blog post that runs a php script to pull and display some data. When any individual blog entry is viewed, it works great, but when I go to the main page, only the first post on the page (no matter which is the first) executes and displays the results…all following blog entries on same page render the blog title but do not execute the php. I’ve played around with the various require and include statements and checked my open closing blocks to no effect. Can’t figure out why this occurs. Thanks much for pondering this.

Malcolm - February 19th, 2010 at 8:01 pm

Thanks for the plugin. It’s great.

Can you make it work for text widgets as well?

I have carefully developed some php code on a page ready to transfer to a text widget once it was completely sorted. However when I came to do this I realised that your plugin doesn’t extend to text widgets!!! Is there an easy way to make it work in text widgets as well?

Cynthia Yockey - February 28th, 2010 at 11:50 pm

After installing PHP Execution, my Firefox browser on my PC stopped loading my blog correctly. Some posts come up with the headline and comments, but no text. Others come up with the headline and text, but not the photo that goes with the post. I cleared the cache many times and re-installed Firefox without fixing the problem. Then I decided to use Firefox on another computer on my network — and it is having the same problems with the blog. So could the plug-in have corrupted code that Firefox uses that Safari, IE and Chrome don’t? My Web host said they couldn’t see any problems on their end.

Thank you.

Trevor - March 19th, 2010 at 7:21 am

Hello, justed wanted to say thanks for the plugin! It’s very useful. I’m on WP 2.9.2 and using 1.0.1 version of the plugin. For whatever reason, PHP code won’t process unless I use <?PHP (uppercase). If I use <?php (lowercase) I get no errors and a nice white screen. My host is Linux but either case works fine in a standard .php page. Just wanted to share in case anyone else has this issue as well. Thanks again.

Manuel Nauta - April 2nd, 2010 at 8:37 pm

Plugin works great.

One question, on the page with PHP, the side menu no loger has the group Pages and Blogroll. When going back to other pages or posts, the Pages and Blogroll group re apears on the side menu in WP

Ricounet - April 4th, 2010 at 10:52 pm

This plugin sounds great but i’m not able to use it.
I’m on WP 2.9.2 and with this code :

last_name . “, ” . $user_info->first_name . “\n”);
in an article I only have a part of the code appearing :
echo($user_info->last_name . “, ” . $user_info->first_name . “\n”);
Could you help me please ?


Kris - April 13th, 2010 at 8:58 am

I am receiving the following error and my PHP is at a begineer level so I am not sure if this problem is in my code or with the plugin. Any helpful suggestions?

Fatal error: Call to a member function search_getMatchingTopics() on a non-object in /home/content/site/html/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()’d code on line 9

My Code:

#get Matching Topics
$matching_topics = $api->search_getMatchingTopics($params);

Kris - April 13th, 2010 at 9:00 am

My Code:

#get Matching Topics
$matching_topics = $api->search_getMatchingTopics($params);

Lisa Cowan - April 13th, 2010 at 9:28 pm

I’m trying to implement an existing form into WordPress and am not having much luck. I’ve tried your plugin and am getting a series of error messages that look like this:

Warning: Unknown(/objects/class.database.php): failed to open stream: No such file or directory in /var/www/html/beta/wp-content/plugins/php_execution/includes/class.php_execution.php(273) : eval()’d code on line 7

Warning: (null)() [function.include]: Failed opening ‘/objects/class.database.php’ for inclusion (include_path=’.:/usr/share/pear’) in /var/www/html/beta/wp-content/plugins/php_execution/includes/class.php_execution.php(273) : eval()’d code on line 7

Warning: Unknown(/objects/class.order.php): failed to open stream: No such file or directory in /var/www/html/beta/wp-content/plugins/php_execution/includes/class.php_execution.php(273) : eval()’d code on line 8

Warning: (null)() [function.include]: Failed opening ‘/objects/class.order.php’ for inclusion (include_path=’.:/usr/share/pear’) in /var/www/html/beta/wp-content/plugins/php_execution/includes/class.php_execution.php(273) : eval()’d code on line 8

Do you have any advice as to how to clear these?

Thank you very much in advance,
Lisa Cowan

John Natoli - May 18th, 2010 at 6:21 pm

Is this plugin compatible with 2.9 yet? Switching to the visual editor is destroying my php code.

barat - May 26th, 2010 at 3:40 pm

When I switch to Visual editor and then go back to HTML – code is messed, parse errors etc.
Can You fix it?

Thomas - June 9th, 2010 at 11:02 pm

I’m running WP 2.9.2 and the plugin works well, but I’m having a frustrating issue. It works for my actual posts page, but it will not work with content that uses excerpts or teasers. I am using the Thesis WP theme. Any help on how to get the code to work in excerpts?

BlueSquares - July 3rd, 2010 at 7:31 pm

Same issue here with uppercase.

For some reason, Wordpress was ignoring my php code until I used uppercase PHP in the snippet. Thanks to @Trevor!!! :)

It was working fine with lowercase before…don’t know what happened.

monbouc - July 15th, 2010 at 1:17 pm

Same issue with uppercase.

Kevin - August 28th, 2010 at 12:14 am

I so far love this php plugin but the one issue I have with this is that it does not parse the php code if the page is down the first directory.

For example

A simple code like works with the domain http://mysite.com/ and http://mysite.com/about/

But it won’t work on a site that has http://mysite.com/about/dr-john

Why is that?


Agnes - August 31st, 2010 at 4:03 pm

This is exactly what I am loking for, as I dont want to swicth off the visual editor for a little php code…
Unfortunately, it seems not work for my case..
I have a page that attempts calling images from the template directory:
<img src="/images/pixel_trans.gif” width=”15″ height=”1″>
WIthout the plugin, it turns the into strange characters when I switch to visual editor
With the plugin, it forgets it is a tag… and turns into
/images/pixel_trans.gif” width=”15″ height=”1″ >
Any way around?

Kevin - September 7th, 2010 at 6:43 pm

Any updates on my issue in comment number 088? I really need this fixed :/

Kevin - September 9th, 2010 at 10:11 pm

I figured it out, it was because the username need to be admin for the changes to be in affect.

randy - September 27th, 2010 at 7:26 pm

4th try at this, tough spam captcha I guess.

I’m fairly new to wordpress, be nice.

Your plugin has allowed me to put polls from advanced polls 2.08 into my blog and they work, yay!. They work when putting in the code directly from the poll admin but show a syntax error on all pages with polls, it also redirects users back to the home page after voting, don’t think that has anything to do with this.

Here is an example of the code from my advanced polls admin page that I’ve simply pasted in the posts:


This is the syntax error I recieve: }

Is the php correct? why the error if you can help.


randy - September 27th, 2010 at 7:29 pm

freakin new guys, of course it won’t work in here to show you an example.


This is the syntax error I recieve: }

randy - September 27th, 2010 at 7:40 pm

The closing /p in brackets is the error

xyw - October 2nd, 2010 at 2:52 pm

I love it.

Valentina - October 28th, 2010 at 11:27 am

I tried everyway to make this plugin works, did everything you told even rename the folder but I got a blank page, it doesn’t execute the script I want to include

I also tried with the relative path but nothing changes!
Can someone help^

Mike - December 15th, 2010 at 11:51 pm


works perfect in normal posts but i am trying to use it with SlideDeck – they use custom posts and apparently if im to use this plugin to embed inline php a config change need to happen with the plugin, can i do this?


Louis - December 20th, 2010 at 2:14 pm

Everything was working until v3 of Wordpress, then the php markers disappeared, which my favourite feature. I debugged the JS file and removed ‘a(document).ready(function(){’ , to get it working. Hope this helps someone else.

JUN SHI - December 21st, 2010 at 4:00 am

Hello, i found a problem in “PHP Execution Plugin”

i write some code like this:

now, in a.php file, i have some code like:

i defined variables in b.php, but when i quote these variables in a.php, the value is null. it means these can’t pass variables.
how to solve this problem, can you help me?

JUN SHI - December 21st, 2010 at 6:42 am

“global” solved my problem. thanks.

EJB - January 5th, 2011 at 7:34 pm

Installed this great plugin and it’s working, but is also throwing out this error when logging into the admin area.

Message: ‘phpExecutionBaseUrl’ is undefined
Line: 8
Char: 161
Code: 0

Tried what Louis suggested in comment 98, which worked but made another error. What would be the best way to resolve this error?

We’re running WP 3.0.4.

Ernest - January 20th, 2011 at 7:30 pm


I’m using your plugin to embed some cexternal code in one post with the code:

Any idea why it doesn’t work?


Ernest - January 20th, 2011 at 7:31 pm


I’m using your plugin to embed some cexternal code in one post with the code:


Any idea why it doesn’t work?


Ernest - January 20th, 2011 at 7:32 pm

Sorry I pasted the code with the php labels and was removed


I’m using your plugin to embed some cexternal code in one post with the code:

Any idea why it doesn’t work?


Ramona - February 2nd, 2011 at 11:40 am

Hello, I finally got this plugin to work but it still has a flaw because if i update the page when i’m in “style mode” the php code is getting messed up, it’s practically replaced by the php image. I’m not sure what to do about that..thank you

Tobias B. - February 7th, 2011 at 3:42 pm


very nice plugin! Just one question: I can’t use $_GET['...] and $_POST['...]. Is it posible to use variables`?

Thanks a lot

Milos L. - February 10th, 2011 at 10:27 pm

Wonderful plugin. It really saved my life. Thanks man!

Wade L. - February 22nd, 2011 at 3:59 am

I recently upgraded to WP 3.0.5 and now I get this warning –
Link to page with error – http://troutpic.com/stream-flows/
Thanks in advance!
Warning: Invalid argument supplied for foreach() in /hermes/web10/b251/moo.rmtroutfitters/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()’d code on line 98

Noah - March 13th, 2011 at 8:33 am

Worked a trick, thank you so much.

Ravi Kiran - March 15th, 2011 at 2:44 am

This plugin doesn’t seem to work with Wordpress 3.1 version. It simply outputs the PHP code entered in a Wordpress page. Does anyone else has similar problems with it ?? Will be glad if someone can finds a fix for this problem…

Ravi Kiran - March 15th, 2011 at 2:45 am

@Noah : Can you please let me know which version of Wordpress are you using ??

Morrers - April 14th, 2011 at 7:20 am

I upgrade just now to wordpres 3.1.1 but now the php what works before show me a error
Fatal error: Cannot redeclare check()
… /class.php_execution.php(274) : eval()’d code:8)

Maybe its about the function, bec other php code works fine.

Eric - May 14th, 2011 at 10:01 pm

I’m having an issue similar to Ravi. Using WordPress version 3.1.2 right now, with PHP Execution plugin version 1.0.0. Here’s the symptom. On the main blog page, I see my raw PHP code. If I click through to a blog entry, on the entry page for that single entry, the PHP code runs as expected. If I go to a category summary page, or author summary page, or tag summary page, the PHP code executes properly. Only on the main blog page do I see the raw code.


Eric - May 29th, 2011 at 12:33 am

Another update. I’m still having issues with this plugin. I get PHP errors on any post which has PHP in it if there is “<!– more –>>” tag on the post. The same post with the same PHP will work perfectly if I remove the “<!– more –>>” tag, but then the entire post shows on the main blog page.

Any ideas what is causing this?

Greg - June 1st, 2011 at 1:48 am

I have a short script, made to link to an image.
Reason is if I go to different pages with a static html link has to change, but I want to keep the image link relative to the index.

So.. I came up with this:
<img src="/wp-content/gallery/images/header.jpg”>

If I put the code in the footer, it works.
And if I put it in the page, it breaks the page,

Any idea what I can do to make this work?
Thanks a bunch

Jasper - June 1st, 2011 at 5:40 pm

Hi Nik,

First of all: thank you very much for the WP plugin.

I am using your plugin on my website to support a integrated PHP guestbook.

With this guestbook, the PHP script on the “Gastenboek” page of my website, needs to run the “ddgb.php” file that is located in the root directory of my website.

I am using the following code:

” ”

With this code, the guestbook appears, but for some reason, the links in the guestbook are not the correct ones.

Instead of using the following links, http://www.totaalvoetbal.nl/ddgb.php?action=entry and http://www.totaalvoetbal.nl/ddgb.php?action=admin, the links on this page of my WP site are http://www.totaalvoetbal.nl/index.php?action=entry

Would you have any idea of what could have gone wrong?

I am sorry for the lenghty message. I hope my question makes sense.



Roy D - June 9th, 2011 at 9:53 am

I looks pretty good, but sometimes the code in the WP Admin editor plays up. Sometimes you get the php as such
ie: inside html comments, and other times all sorts of strange markup. Im using WP 3.1.3

Roy D - June 9th, 2011 at 9:55 am

Oops I should of escaped that, here lets try that again:
<!–?php SomePHP(); ?–>

Jasper - June 9th, 2011 at 4:19 pm

@ Roy D – should I put the above PHP code somewhere? Or should I replace the “SomePHP” with the PHP file that I need to run in through the PHP execution plugin?

Jasper - June 9th, 2011 at 4:24 pm

PS: I am also on WP 3.1.3

Lisa - June 14th, 2011 at 9:40 pm

I am getting this error:
Parse error: syntax error, unexpected ‘>’ in /home/myname/public_html/exhibits/wp-content/plugins/php-execution/includes/class.php_execution.php(271) : eval()’d code on line 1

Any ideas?

Lisa - June 14th, 2011 at 9:41 pm

Sorry, also on 3.1.3

José Luís - June 15th, 2011 at 3:14 am

Hi! Great plugin!

What about widgets? Do you plan on supporting them?

Colin - June 30th, 2011 at 5:31 pm

Hi running WP 3.1.1 with Formidable Forms.
All works fine until I view a form with the text “remote-mail retrieval” in it.
The error I get is: Warning: Failure in /home/…//php-execution-plugin/includes/class.php_execution.php on line 273

finndo - July 13th, 2011 at 2:19 am

having the same issue with Wordpress 3.1.2, going to check and see if I accidentally typed ?> or <? in my blog post…

Parse error: syntax error, unexpected ‘<' in /home/finndo/joelperryproductions.com/wordpress/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()’d code on line 48

finndo - July 13th, 2011 at 2:33 am

yeah, figured it out, I copied and pasted my page (writing in html mode) into a text editor and did a search for php codes, I accidentally put a instead of

Jim R - August 5th, 2011 at 4:16 am

Using WordPress 3.2.1, and the php keeps breaking when I update a page/post.

Any thought?

PHP Execution review, discussions, does it work, and ratings on Loadwp.com | Loadwp.com - August 17th, 2011 at 1:57 pm

[...] Further information at zehnet.de: PHP Execution Plugin home [...]

John Pizzolato - September 4th, 2011 at 1:04 am

Wordpress version is 3.1
My Wordpress Page (test) has the following:

the test.php file in the scripts folder has the following:

The result —- the echo display is not showing up from the php file. I also am getting the same results with HTML code in the test.php file… no display.

Has anyone reported this type of problem before?? Any help would be very appreciated. Thank you


John Pizzolato - September 4th, 2011 at 1:12 am

Wordpress version is 3.1
My Wordpress Page (test) has the following:

PHP symbol ()

the test.php file in the scripts folder has the following:
PHP symbol ()

The result —- the echo display is not showing up from the php file. I also am getting the same results with HTML code in the test.php file… no display.

Has anyone reported this type of problem before?? Any help would be very appreciated. Thank you


John Pizzolato - September 4th, 2011 at 1:17 am

Let me try this one more time:

I am using Wordpress version 3.1

From the Wordpress Page called test, I am calling a php file using the require_once statement. I have the php starting symbols and the php ending symbols

In the php file I simply have an echo statement and then the same php return symbol.

The result —- the echo display is not showing up in the Page from the php file. I also am getting the same results with HTML code in the test.php file… no display.

Has anyone reported this type of problem before?? Any help would be very appreciated. Thank you


Kjetil - September 14th, 2011 at 5:34 pm

Decent effort but I have no luck with the plugin; the php tags are stripped out when changing to Visual mode. I have a small tingeling it is because of the multilingual plugin I’m using (qTranslate) which alters the editor. As the javascript in editor_plugin.js is compressed I cba ebugging that..

Any help would be appriciated.

Abhishek - October 24th, 2011 at 11:52 am

It works fine. cool. thanks

LxCBLOG - November 16th, 2011 at 10:47 pm


You can Run, execute or include PHP Code in WordPress Posts without a Plugin. Check out the script http://lxcblog.com/2011/11/05/run-execute-include-php-code-wordpress-posts-no-plugin/

Hope you like it.

liquinas - November 30th, 2011 at 8:39 pm

I installed unfiltered MU and was still having problems getting the plugin to work. The javascript it’s supposed to add to the code just wasn’t working.

In includes/class.php_execution.php @ line 190 this function is supposed to print out the javascript definition of the plugin directory.

To fix just open assets/editor_plugin.js and add a new line at the top of the file:

phpExecutionBaseUrl= ‘/wp-content/plugins/php_execution/’;

Not sure what is causing this but in either case this should hold until an official update is released. Hope this helps someone.

wholesale hats - December 13th, 2011 at 5:36 am

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work.

Zac - January 25th, 2012 at 7:00 pm

Been using this happily for a while now, all of a sudden it has stopped working, is not showing the php block image in the visual editor, is mangling the code when switching between visual/html view and is not running the php when the_content() is called.

Quite urgent as is running on a fairly well used site for a client, any ideas what’s happened?

Am using WPMU 3.1.2

Norberto - February 6th, 2012 at 11:37 am

… same to me after updating Wordpress!
Now it still works in the html-editor but switching to the visual-editor its being killed completly.
(Wordpress’ tag balancing is turned off.)


Muthukumar.G - February 21st, 2012 at 10:58 am

like it …….Thanks Genious

Don Gillespie - March 9th, 2012 at 8:59 am

The PHP Execution Wordpress plugin is really well-written and extremely useful to me. Thanks for your good work!

Running fine in Wordpress 3.1.

Njanga - March 12th, 2012 at 11:41 am

Thank you for this plugin. It work perfectly. I have made at least five unsuccessful attempts with other plugins.

Good job.

lucho - March 28th, 2012 at 2:17 pm

Hi nice plugin but…
it seems to have pb with WordPress 3.3.1 when we use visual editor then come back to code editor.
For example my code :
<a href="” rel=”bookmark” title=”">
is replaced by :

any help is welcome!

wholesale hats - October 18th, 2012 at 5:55 am

The PHP Execution Wordpress plugin is really well-written and extremely useful to me. Thanks for your good work!

PHP Execution Plugin-wordpress插入php代码 | 重华部落格 - October 23rd, 2012 at 1:52 pm

[...] 截图和使用说明页面:http://www.zehnet.de/2009/02/25/wordpress-php-execution-plugin [...]

Bruce Springsteen Tour 2013 - December 6th, 2012 at 3:34 am

Thank you for your great Informations

Will come back later to read some More articles

PHP Execution | 投稿記事内で PHP を実行させるWordPressプラグイン - December 14th, 2012 at 3:49 pm

[...] 配布サイト(作者のサイト):WordPress PHP Execution Plugin – zehnet.de [...]

PHP Script Installation Service - December 20th, 2012 at 8:55 am

[...] Our team can install any PHP/CGI/Perl script e.g. Blogs, CMS, Forums, Directories etc. Installation charge starts at $10 per script. Source Page: http://www.zehnet.de/2009/02/25/wordpress-php-execution-plugin/ [...]

Mr Big Dog - January 26th, 2013 at 5:10 am

Works great, but my error log is full of:

syntax error, unexpected T_VARIABLE in /var/www/knowledge/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()’d code on line 7

Line 7 is commented out?

PHP Execution | Best Plugins - wordpress – widgets – plugin 2012 - February 4th, 2013 at 10:20 pm

[...] Further information at zehnet.de: PHP Execution Plugin home [...]

Risotto » Извлечение php в WordPress MU - February 7th, 2013 at 8:02 pm

[...] Согласно данным на сайте создателя плагина, PHP Execution должен работать даже с включенным визуальным редактором, хотя такой вариант я не проверяла. [...]

Texas NFA Trust - June 13th, 2013 at 4:14 pm

It works fine for me in the sidebar. After installing and activating the plugin, can add php code to the “Text” box in the sidebar and it works fine.

ton - June 20th, 2013 at 7:44 am

Not work!!!…..
wordpress visual editor create space between php tag

it’s look like this in html editor

it’s look like this in visual editor

 ?php echo “test”; ? 

Sylvain - August 12th, 2013 at 10:30 am


The plugin stopped working since I upgraded WP to the latest version (3.6). Am I the only one?

Validation: validation