How to execute PHP code in Text Widget without using Plugin?

By August 28, 2017 PHP, WordPress 2 Comments

Executing php code inside a WordPress widget, without Using any plugin.

Recently in  a project i needed to add php code in theme widget area to perform some action. I googled and found many of plugins by that i can achieve what i am looking for, but after some search on google, i found that i don’t need to install any plugin for such a simple task, number of code spinets can perform this with perfectly.

Same with other developer in WordPress may need to execute custom php code in a widget area in your theme, because you want to display different information according to your site need.

Here i am showing some working and useful code snippets to Executing php code inside a WordPress widget, without Using any plugin.

Just add  following snippet to your current theme’s functions.php file:

(Use only one of them from below)

 

Solution 1

 

Solution 2

 

Solution 3

 

Solution 4

 


[paypal-donation]

About Vijay Dhanvai

A passionate blogger by heart and mind, I have been working in this field for 10 years now. A WordPress Professional, web developer and designer who intends to guide his readers about Web Design, WordPress, Blogging, Web Development, and more.

2 Comments

  • Criss Angle says:

    I am so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that’s at the other blogs.

  • Edward Mark says:

    Things are very open and intensely clear the problem with clear explanation. was truly information. Your website is very beneficial.

Leave a Reply to Edward Mark Cancel Reply