Skip to content

Instantly share code, notes, and snippets.

@jessbudd
Created February 14, 2018 05:43
Show Gist options
  • Save jessbudd/11658238ffdcd3e3b2ea1ac6678e9a94 to your computer and use it in GitHub Desktop.
Save jessbudd/11658238ffdcd3e3b2ea1ac6678e9a94 to your computer and use it in GitHub Desktop.
Add this codeblock to your functions.php file:
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;
}
Code courtesy of http://www.emanueleferonato.com/2011/04/11/executing-php-inside-a-wordpress-widget-without-any-plugin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment