June 16, 2020
June 16, 2020
Looking to know how to run PHP code on a WordPress post or page? You’ve come to the right place. Here, we will uncover how to add PHP to a WordPress page or post so you can improve their functionality.
Upgrade to WordPress Hosting with Hostinger today! With a guaranteed 99.99% uptime!
By default, WordPress doesn’t allow you to run PHP code in posts or pages. The recommended way to add PHP functions is to modify the child theme or create custom page templates.
Despite so, there are occasions where you might want to add specific PHP functions to an individual post or page. In these cases, you can override the rule using WordPress code widget plugins.
The following tutorial will guide you through the process of using the Insert PHP Code Snippet plugin to add PHP code directly to a WordPress post or page.
Before diving into the tutorial, make sure you have installed and activate the Insert PHP Code Snippet plugin. Check this tutorial for a thorough instruction on how to install and activate a WordPress plugin properly.
Just because WordPress doesn’t allow you to run PHP code in a post or page, it’s not impossible to do so. Using WordPress code widget plugins, you can add various PHP functions to your posts or pages easily.
Do you find this tutorial helpful? Let us know in the comments section below!
May 16 2017
Thanks it was easy and great.....
May 28 2017
Thanks you very much i was searching for php code in wordpress like this
November 04 2017
I did exactly as you say but this plugin doesn't work properly, it is crap.
Replied on November 10 2017
Hey Devon, Why, do you get any errors? Provide more details, please.
Replied on December 19 2017
No errors, just doesn't work. No more details required.
November 08 2017
Is it possible that it doesn't work for 'pages'?
Replied on November 21 2017
I did exactly as you say but it doesn't work. It shows this message: Parse error: syntax error, unexpected ‘&’ in /home/nt435/public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 3
November 23 2017
Thank you Guys
April 17 2018
This plugin worked for me... had to deactivate some plugins before i got it to work
August 31 2018
Thanks a lot!
March 16 2020
You can consider: https://wordpress.org/plugins/ultimate-shortcodes-creator/. You can inject whatever code through a custom shortcode.
April 28 2020
Amazing content, thank you!
August 11 2020
Work for me