Execute php code in WordPress widgets

Turbo SEO Tools

Execute php code in WordPress widgets

03/23/2018 12:00 AM by Admin in Wordpress

WordPress widgets area is an important element to design a website. You can display your site’s related post, recent post, random post and other what you want to display using WordPress widgets area. In these Web developer resources, I will share a simple WordPress snippet that will help to Execute PHP code in WordPress text widget.

Simply add the below WordPress snippet to your theme ’s filefunctions.php.

function execute_php($html){
return $html;

After adding this WordPress snippet your default WordPress text widgets will support PHP codes.

PHP enable WordPress text widgets

To test PHP codes in WordPress widgets area simply add some PHP codes in your WordPress default text widgets and see the result. You can try the following sample of PHP codes in WordPress text widgets.

 //Gets the IP address
 $ip = getenv("REMOTE_ADDR") ;
 Echo "Your IP is: " . '<b><span>'.$ip .'</span></b>';

This code will display your IP address Where you place Your widgets it may be sidebar or footer area.

Try Pro IP locator Script Today! CLICK HERE

Get 20,000 Unique Traffic for $5 [Limited Time Offer] - Buy Now! CLICK HERE

A to Z SEO Tools - Get Now for $35 ! CLICK HERE