anurag-singh
9/18/2015 - 10:43 AM

How to use php in WP text widget

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;
}

// Then call the image in text widget like, <img src="<?php echo get_bloginfo('stylesheet_directory');?>/image_folder_name/image_name.png">