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
Download the Proper PHP Include 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:
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.
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.
Works with the latest version of WordPress.
Requires WordPress 3.0 or higher.
Check out our WordPress plugins page for more cool WordPress plugins.