Run PHP Code in WordPress Posts and Pages


Insert PHP Plugin

Run PHP code inserted into WordPress posts and pages.

The PHP code is between special tags (“[insert_php]” instead of “”).

The PHP code runs as the page is sent to the browser. Output of the PHP code is published directly onto the post or page where the PHP code between the special tags is located.

The code between the tags must be complete in and of itself. References to variables or code blocks outside the area between the tags will fail. See the “more information” URL for an explanation of this.

Using Insert PHP

To use, paste the PHP code into the post or page and then:

Write PHP code between [insert_php] and [/insert_php]

echo "Hello, World!";
echo "You are my friend :)";

Installing Insert PHP

Insert PHP can be installed from the WordPress Dashboard or uploaded to the /plugins directory.

To install from the WordPress Dashboard:

At the “Plugins – Add New” dashboard menu item:

Search for “Insert PHP”

Click the plugin’s “Install Now” link.

To upload to the /plugins directory:

Download Insert PHP from either the plugin page or directly from this link.

Unzip the downloaded file.

Upload the unzipped “insert-php” directory to the WordPress /plugins directory.

When Installed or Uploaded:

After Insert PHP has been installed via the dashboard or uploaded into the /plugins directory, activate the plugin.


Bypass FTP in wordpress


Write below lines at the end of  your wp-config.php
define( 'FS_METHOD', 'direct' );
define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );

Add Custom Shortcode in any Post Type


If you need to add custom shortcode in your site then this article is useful to you.

Add below Function in your theme’s function.php.

function get_value($atts) {
$output = $arr[$atts['key']];
return $output;

add_shortcode('variable', 'get_value');


[variable key="IMAGE_PATH"]

add above line in worpress editor(in your post).

Also refer this link for more detail.