2

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?

5 Answers 5

2

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?

Sign up to request clarification or add additional context in comments.

2 Comments

The issue is that for earlier posts, it would be replicating the tags I've placed. Also, there's a bunch of other problems to do with how I structure every post. I've thought about this option and found it wouldn't work.
@JackGriffiths: You can do this in your theme, no need to change previous posts.
2

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

Comments

2

Goes like this:

Done.

Comments

0

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/

Comments

-1

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()

1 Comment

URL ends in 404

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.