WP Proper PHP Include Plugin

WordPress, by default, allows the use of HTML and JavaScript when adding/editing posts and pages in “Text” view. However, PHP execution is a different story.

Sometimes you may want to execute some PHP code in your post or page and this plugin will allow you to do that.

There are a few plugins that allow you to execute PHP code inside a WP Post. This plugin is slightly different as it lets you include a PHP file just by using a shortcode. So you write your PHP code in a file then include and execute that file using a shortcode introduced by this plugin.

You can execute simple or complex PHP within WordPress posts. It can get tricky when wanting to include other files within your include, but essentially anything that you could typically do with PHP is fair game.

Download the Include PHP Plugin

Installing the PHP Include Plugin

Below are the steps for setting up and using the plugin.

  • Go to the Add New plugins screen in your WordPress admin area
  • Click the upload tab
  • Browse for the plugin file (proper-php-include.zip)
  • Click Install Now and then activate the plugin

Using the Plugin

Step 1) For immediate use, upload a PHP file to your current theme folder and place a shortcode within a post, page or widget like this:

[tthq_include_file tthq_file="filename.php"]

Step 2) I like using the theme folder for my PHP files because it makes it simple to make edits because the Theme Editor could be used. Some people, however, like to keep their includeds elsewhere saving grief when wanting to switch themes.

To override the hardcoded deault folder (the current theme folder) with a new default, simply go to: Settings >> Proper PHP Include and fill the empty box with a new path. Use the template path that is output to the screen as a guide when choosing a new path.

Always include a trailing slash when specifying a path.

proper php include settings

Step 3) If for some reason you want to use a different path but just in a specific instance, simply add an extra value (for tthq_path) to the shortcode like this:

[tthq_include_file tthq_path="/path/to/specific/php/file/" tthq_file="filename.php"]

The above will override the default path. Again, always include a trailing slash when specifying a path.

Plugin Compatibility

Works with the latest version of WordPress.

Plugin Requirement

Requires WordPress 3.0 or higher.

Check out our WordPress plugins page for more cool WordPress plugins.


  1. denbo says:

    Simply brilliant – adding a PHP routine into my (simple) WP theme thing was driving me nuts.

    This just worked instantly

    Thank you

Speak Your Mind