I need to run some code in every WordPress article.
The problem is, by default, WordPress does not execute any PHP in posts. I’ve tried a wealth of plugins (including ExecPHP and suchlike) but to no avail. How can I get PHP to run in WordPress?
I need to run some code in every WordPress article.
The problem is, by default, WordPress does not execute any PHP in posts. I’ve tried a wealth of plugins (including ExecPHP and suchlike) but to no avail. How can I get PHP to run in WordPress?
You must be logged in to post a comment.
is it the same code for every article? if so why don’t you change the wordpress file that creates the post and add the code in there?
This is dangerous as it can crash your entire site if it’s not secured properly, but you may use the php function eval() to execute php code.
See:
http://ca.php.net/manual/en/function.eval.php
Goes like this:
Done.
You can use “PHP Code for posts” plugin for this, after enable this plugin you will be able to run php code in wordpress editor like any php editor to run your php code you must write your code in php tags. you can download this plugin from here
https://wordpress.org/plugins/php-code-for-posts/
This plugin will save you the hassle of having to make separate custom plugins:
http://www.hitreach.co.uk/wordpress-plugins/allow-php-in-posts-and-pages/
However as others have suggested this does potentially open security exploits as it’s likely this code will utilise eval()