I would like to use PHP in some posts. These posts should look like normal posts, be in the archive and categories like normal posts an have tags.

I don't need PHP in every post, but it would be great if I could use it in some.

I saw that it is possible to create custom page templates which seems to be almost what I want, but I want it for posts. How can I get it?

2 Answers 2


You can edit the single.php and/or content-single.php files in your theme.

Then it depends what you mean by "some". You could apply some conditions to your code (only certain categories, certain tags, certain specific post IDs only, etc.)

You could also create a custom post type "myspecialposts" and create single-myspecialposts.php (codex)


A quick search gave me these: http://wordpress.org/extend/plugins/runphp/ and http://wordpress.org/extend/plugins/exec-php/ and more here: https://www.google.com/search?q=WordPress+php+in+posts

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.