
If you are still struggling on how to insert PHP Codes inside particular blog post, page or a widget sidebar for execution; the following tutorial is for you.
Executing PHP codes in Wordpress Page/Post
Installation
- Download phpexec.txt
- Rename phpexec.txt to phpexec.php
- Upload to /wp-content/plugins/ directory
- Activate the plug-in from Wordpress administration menu
Usage
Anywhere in your post/pages where you want to execute a PHP Codes, insert <phpcode> before your php codes and </phpcode> your php codes.
<phpcode>
<?php
echo "Current date and time: ";
echo date("l dS of F Y h:i:s A");
?>
</phpcode>
Security
If you are running a blog with multiple users, you need to determine who can run this plug-in. Alter the settings in your Administration Menu. Options -> PHPExec
Executing PHP codes in Wordpress widget sidebar
Installation
- Download execphp.txt
- Rename execphp.txt to execphp.php
- Upload to /wp-content/plugins/ directory
- Activate the plug-in from Wordpress administration menu
Usage
This plug-in work like a normal text widget except that it allows execution of PHP Codes. You can create up to 9 instances of this widget. 
Don't miss any post. Subscribe to Hongkiat's RSS feed now.
Related Contents |
Sponsors |
|
Posted by hongkiat in Wordpress, Wordpress Plugin , at 02.18.07
|
|


























Comments
CincauHangus February 18th, 2007
does it work with other wysiwyg editors like xinha4wp ?
Replyhongkiat February 19th, 2007
Hm, I don’t think it will work in any WYSIWYG textbox. What you put in WYSIWYG is what you will see for output.
I’ve never used xinha4wp before, not really planning to use WYSIWYG to write my entries :)
ReplyCincauHangus February 19th, 2007
what i meant was using a wysiwyg editer, switch to see the html coding, then add the code there. would it still work? because there’s some editors that will discard unrecognised tags when posted… therefore the code wouldnt work.
aah. a html coder i see :P i’m somewhat in between. :P
Replyhongkiat February 20th, 2007
Yeah, that’s what i mean :) Me using the coding mode, the tag works fine.
ReplyAshish Mohta February 20th, 2007
I ad been using the plugins from long time.But never used them inside the post.I am not able to understand what i can run inside my post.
Replyhongkiat February 26th, 2007
One good example would be Alex King’s popularity content plugin where you need to put “Top X Popular Content” on your sidebar. It requires phpcode, there’s where this sidebar php-insert comes in handy :)
ReplyThilak March 2nd, 2007
I had been using this while i was on Wordpress 1.5.x, but does it work with Wordpress 2.1.1 now ??
Replyhongkiat March 3rd, 2007
I’m still on WP 2.1. Are you sure it will not work with WP2.1.1? Hmm, something I should put on check list before upgrading.
ReplyAntonie Potgieter March 3rd, 2007
I’m using WP2.1.1 and it doesn’t seem to work.
ReplyIs there an alternative method to this?
Steven Sashen March 4th, 2007
I’m using 2.1.1 and I can’t get it to work either… what I see is the php code (but note the tags)
Am I doing something wrong?
Replyhongkiat March 4th, 2007
It is working for Wordpress 2.1.0 but however I noticed few saying its not working for Wordpress 2.1.1. I’ll update here once the authors have updated their plugins.
Replyroyalblogger March 14th, 2007
Same here, not working with 2.1.1.
ReplyGary Speer April 9th, 2007
Anybody found out more about getting the execphp widget to work in WordPress 2.1.3?
I can’t get it to do anything but display the php code or give me an error related to line 24, I think it is.
Any help? Hope? (grin)
Replystephen April 12th, 2007
i haven’t tested this yet, but for you 2.x.x+ users, try out this link here
http://activeblogging.com/info/phpexec-2/
Replyblogger tools April 22nd, 2007
Exactly what I was looking for.
I need to include a php script in my pages.
I hope this plugin will be updated for the latest and coming versions of wordpress.
and thanks for making life easier for us wordpress bloggers ;)
Replynazlihaffiz May 6th, 2007
i’m using 2.1.3 in my other website at http://www.drnazlihaffiz.com and found that phpexec wasn’t working.
the fact is it is working, only that you don’t have to type and all that. just put in your codings into the post but remember to edit the post in the code tab (not visual).
hope this helps.
cheers ;)
ReplyTed July 8th, 2007
Thanks, worked a treat.
ReplyPatu July 29th, 2007
Hi, phpexec-2 dont work with wp 2.2.1 :(
Help!!!
Replysealinda December 3rd, 2007
Thanks so much for these codes, they are the way out for me!!! thanks!
ReplyDan Kelly December 14th, 2007
I love the simplicity of your script…
It would be better if it actually worked for me. :-(
I’m using the latest version of WordPress - 2.3.x.
And, when I use the “Code” tab (even when I turn the visual editor off) and ender the following:
In my post, I see:
Any ideas on how to get it to work with wp v2.3.x?
Thanks!!
ReplySherry March 3rd, 2008
Thank you so much for this. I was going nuts trying to find out how to get php to work in my custom plug-ins. Your code is essential, in my opinion! I will definitely support your site and will be back in the future.
ReplyAlfie May 12th, 2008
Will it work on WP 2.5?
ReplyAntonJamm May 13th, 2008
Unable to get working on v2.5, looking at RunPHP right now
ReplyJudah Mu June 5th, 2008
Is php’s:
Replyinclude_once (’/myOther.php’); supported in pages and posts? Can’t seem to get it working… Other php functionality is working on WP2.1.2
Steven June 24th, 2008
My phpcode function stopped working!! It was working perfect on WP 2.5.1 :(
I deactivated all plugins but phpexec, re-uploaded the script but nothing seems to help.. code is visible in posts :( Managing pages was saved in HTML-view. I host my own WP so have full control. What else can I try? Really need help on this.
Replypaul mall June 26th, 2008
I have had some bugs in zended php files that prevented my site from running properly.
I finally found a program that can decompile the zended script. The website is for site owners who have lost their source code.
http://www.decode-zend-decoder.com
Hope this helps someone who is stuck like I was.
ReplyMario August 16th, 2008
Hello, not working at all for me with the following query in wp 2.5.1
posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->postmeta.meta_value = 'Arezzo'
ORDER BY $wpdb->postmeta.meta_value ASC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
<div class="post" id="post-">
<a href="" rel="bookmark" title="Permanent Link to ">
Sorry, but you are looking for something that isn’t here.
Any idea?? Thanks
ReplyMario August 16th, 2008
Mmmmhhh the code in my prev comment got cut out…hope you get the whole deal on the admin side
ReplyPinara.Net August 29th, 2008
That plugin is save?
ReplyJas September 5th, 2008
Amazing Plugin and want to let you know its working with Wordpress 2.6 Also :)
ReplyJas September 5th, 2008
Hi,
:( It was running from my cache, but got a nice solution! Chec this:
Replyhttp://www.free-mobile-4u.co.uk/wp-content/plugins/exec-php/docs/readme.html#tag_balancing
Danno September 17th, 2008
Excellent plugin. Thanks so much. Workin’ just fine here on 2.6.2.
ReplyLarry Bradshaw September 19th, 2008
I tried this and still got nothing but text on my page.
ReplyMaclin September 25th, 2008
hi,
Replyits good site
Steve Rial October 3rd, 2008
It worked absolutely perfectly and was exactly what I needed. Thanks for the good work.
ReplyTrackbacks