Plugin Directory

Insert PHP

Run PHP code inserted into WordPress posts and pages.

How do I use this thing?

Make a copy of the working PHP code to be used in a post or a page.

Replace "<?php" on the first line with "[insert_php]". Replace "?>" on the last line with "[/insert_php]".

Paste the code into your post or page.

Examples are here: http://www.willmaster.com/software/WPplugins/go/iphpinstructions_iphplugin

Can I have more than one place with PHP code on individual posts and pages?

Yes. I have found no limit to the number of places PHP code can be inserted into a post or page. Probably there is no WordPress software limit. There may be a server memory limit of your PHP code uses a lot of memory.

Does the PHP output need to have paragraph and line break HTML formatting codes?

No. HTML paragraph and line break formatting are applied to PHP output.

Do I put the PHP code into content at the "Visual" tab or the "HTML/Text" tab?

Use the HTML/Text tab. While the Visual tab will, sometimes, the HTML/Text tab allows working with the code without the visual formatting.

Why can't I set cookies or do a browser redirect?

With PHP, cookies are set in the web page header lines, before any page content is processed. Redirects, too, are done in the header lines. When PHP code is within a post or a page, all the header lines have already been sent, along with part of the content. At that point, it is too late to set cookies or redirect with PHP.

I get a "Parse error: ..." What do I do now?

Unless the source code of the plugin has been changed or somehow became corrupted, the parse error is likely to be in the PHP code inserted into the post or page. Example:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /public_html/wp331/wp-content/plugins/insert_php.php(48) : eval()'d code on line 5

Either within or at the end of the parse error message you'll find something like this:

eval()'d code on line 5

The error is on the indicated eval()'d code line number of the PHP code you are inserting ("5" in the example). At the PHP code you inserted, count down the number of lines indicated. You'll find the error at that line.

If you have PHP code inserted in more than one place, the error message may apply to any of those places. Temporarily remove or disable them, one at a time, until you determine which one the error message applies to.

If Insert PHP is used with an include() function, the include()'d file may be spawning the error message. In that case, the file name being include()'d and the line number of the error should be somewhere within the error message.

When the error is located, correct it and try again.

Requires: 3.3.1 or higher
Compatible up to: 3.8.8
Last Updated: 2013-12-31
Active Installs: 50,000+


4.7 out of 5 stars


1 of 8 support threads in the last two months have been resolved.

Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

100,2,2 67,3,2
100,1,1 100,1,1