PHP in wordpress widgets

In this how to write the php code in wordpress sidebar widgets

Step 1: Add the below code in functions.php to write the php code in wordpress widgets

add_filter('widget_text','execute_php',100);
function execute_php($html)
{
 if(strpos($html,"<"."?php")!==false)
{
 ob_start();
 eval("?".">".$html);
 $html=ob_get_contents();
 ob_end_clean();
 }
 return $html;
}

Step 2: Add the below code in text widgets  and check it

<?php 
echo "Greate tutorial in webprow";  
?>

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of