LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » WordPress / WordPress Tricks » How To Execute PHP In WordPress Text Widget Without A Plugin?

How To Execute PHP In WordPress Text Widget Without A Plugin?

How-To-Execute-PHP-In-WordPress-Text-Widget-Without-A-Plugin
Default text message widget throughout WordPress doesn’t have got the capacity of making PHP rule. If you would like execute php rule throughout WordPress text message widget with no plugin, comply with this particular uncomplicated strategy. Several extensions are available to be able to execute php throughout sidebar widgets, but instead of employing a plugin this particular functionality might be easily attained with the addition of this particular rule.

Now if you want to run a PHP code without editing your theme files as you dont know how to edit and if you do it incorrectly then it can mess up your blog design too so if you have any widget code in PHP then we will recommend you to follow this process for you all upcoming widgets snippets too.

How To Execute PHP In WordPress Text Widget Without A Plugin?

Step 1:) Copy the below code and Paste in your Theme Function(function.php) file.

/* ------------------------------------------------------------------------- *
* Execute PHP In WordPress Text Widget
/* ------------------------------------------------------------------------- */
function php_execute($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
return $html;
}
add_filter('widget_text','php_execute',100);

Step 2:) Update and done.

Customization:

You do not have to change anything. Just after adding this code, go to your Widgets and add a text widget. Now in the text area, just add your PHP snippet code and save that widget. You can also show simple text in that too.

Theme Files Editing Warning:

Keep in mind that every code that you will add in your themes files will be removed when you will change the theme. So after changing your theme, you have to follow this article again and you will get everything back same as it is now.

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *