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";  
?>
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Top News

Follow Us

0
Would love your thoughts, please comment.x
()
x