Catalyst Theme - WordPress Accelerated

How to run PHP in WordPress Posts?

| February 9, 2010 | 7 Comments More

I bet many bloggers would love to run PHP from inside the posts. Running PHP from inside the post would enable us to do a lot of things, for example, add random advertisments.

Till now I have come to know of supposedly three plugins which will allow you to use PHP from inside your posts, pages and widgets. The three are RunPHP, PHPExec and Exec-PHP. From among this only Exec-PHP is WordPress 2.9.1 compatible.

Features of Exec-PHP are as follows:

* Executes PHP code in the excerpt and the content portion of your posts and pages
* Configurable execution of PHP code in text widgets (for WordPress 2.2 or higher)
* Write PHP code in familiar syntax, eg.
* Works in your newsfeeds
* Information about which users are allowed to execute PHP with the current security settings (for WordPress 2.1 or higher)
* Configurable user warnings for inappropriate blog and user settings (for WordPress 2.1 or higher)
* Restrict execution of PHP code in posts and pages to certain users by using roles and capabilities
* Update notifications through the ‘Plugins’ menu in WordPress if a new version of the Exec-PHP plugin is available (for WordPress 2.3 or higher)
* Internationalization support (english and german included, many more available)
* Comes with documentation

How to Install the plugin:

Well it is very easy either go to your plugin section and search for Exec-PHP else download Exec-PHP from here. AFter it is installed activate it.

Configuration

The plugin comes with its own configuration menu that is accessible through ‘Settings > Exec-PHP’. The configuration menu is only accessible for users that do have the ‘edit_plugins’ capability. This is usually only assigned to the Blog Administrator. If you have disabled Javascript or you are running Exec-PHP with WordPress 2.0.x you will not see or only see parts of the plugin configuration menu.

The configuration menu is divided into two parts, the Settings section and the Information section. In the Settings section you can adjust the plugin’s behavior to your needs while the Information section shows which users are allowed to execute PHP code.

The Exec-PHP configuration menu

Misconfiguration

If the blog or user settings are not appropriate to write PHP code, you will get a warning on the ‘Write’ dialog or ‘Widgets’ menu respectivly.

An Exec-PHP warning in the 'Write' menu

The WYSIWYG Convesion Warning can be turned off through the ‘Users > Your Profile’ menu. Nevertheless, this is not the recommended way, because this can cause you to accidently render PHP code in articles permanently unuseful.

Exec-PHP warning configuration in the 'Users > Your Profile' menu

If you have disabled Javascript or you are running Exec-PHP with WordPress 2.1.0 you will not receive any warnings even if your blog or user settings are not configured appropriately to run Exec-PHP.

For support and further information about the Exec-PHP plugin see the plugins homepage at http://bluesome.net/post/2005/08/18/50/.

Tags:

Category: Internet Tips

About the Author (Author Profile)

Shiva Chettri is the editor and owner of Netchunks, a premier blog about Webmaster and Blogging Tips. He intends to make the web a friendlier place by sharing stuffs and articles which will help other webmasters and bloggers to becomes successful. His other interests includes Web Designing, Wordpress and Music of almost every genre. Send Shiva Chettri an email at admin@netchunks.com

Comments (7)

Trackback URL | Comments RSS Feed

  1. TechChunks says:

    Love your comment form. It integrates so seamlessly with your current theme :)
    .-= TechChunks´s last blog ..The Buzz About ‘Google Buzz‎’: It’s too Late, Dull and Probably Going to Flop =-.

  2. Great …..

    PHP in wordpress post…….

    Looking forward to read it………..
    Digital Imagination recently posted..The Week in TechnologyMy Profile

  3. Chethan says:

    hey this comment form is really awesome… have used any execPhp here?
    Chethan recently posted..New iPhone app, Pepsi Loot. Get freebies for an entry in restaurants!My Profile

  4. Rohit says:

    can i used it with wordpress 3.01?
    Rohit recently posted..Online create Favicon for your Blog Website easilyMy Profile

  5. sharal says:

    im using Exec-php plugin with evening shade theme but it is not displaying php code and text is displayed on page with php tags like
    can you help me to solve my problem

  6. Robert says:

    Hey that is really a nice way to have and really liked the way you presented the post, very easy to follow.
    Keep writing good posts like this
    Robert recently posted..IntroMy Profile

  7. mikey says:

    I’m having the same problem as sharal – the < and ? in the php tags keep separating like < ?php – and the php isn't executed..

Leave a Reply

CommentLuv badge
This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 3 approved comments. Use your real name and then @ your keywords (maximum of 3)