Use PHP in WordPress

Sometimes, it becomes necessary to run a PHP code in your wordpress posts or pages to display a plugin output or for other reasons to make use of wordpress as a powerful CMS. There are virtually countless plugins which allow you to run PHP in wordpress.

WordPress PHP exec” is a plugin that lets you execute dynamic PHP code in posts. It masks PHP code before balanceTags, and unmask them afterwards, so it should be safe to use PHP code that has literal HTML tags in it, for example: code which print out HTML.

For example, you can put you PHP codes like

<phpcode>
<?php
echo “Current date and time: “;
echo date(“l dS of F Y h:i:s A”);
?>
</phpcode>

and get your output inside your page/post.

Download PHP Exec Plugin for Wordress here.


Comments

6 responses to “Use PHP in WordPress”

  1. Thanks Anand, will check it.

    1. Glad to be of help…i used to take this plugin for granted until recently ๐Ÿ™‚

  2. Jamie Avatar

    is it possible for every one to put in php codes into a post? I do not want my readers to insert php codes and spoil my blog. . .. ๐Ÿ™

    1. ah….these php codes in wordpress work only when you are putting up a post. Not in the comments section. Also, they work only for the authorized authors like the admin. Normal authors cannot do it.

  3. I have been using this plugin for a long time. If you want to use php in widgets you can do so using Executable PHP Widgets : http://wordpress.org/extend/plugins/php-code-widget/

    1. using php in wordpress widgets is a rocking idea for those who might not be interested in learning code to implement a plugin….thanks @pallab! ๐Ÿ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *