PHP in WordPress Text Widget
Allow PHP in WordPress Text Widget. No plugin, functions file solution.
Add the following code to functions.php in child theme folder:
add_filter('widget_text', 'php_text', 99); function php_text($text) { if (strpos($text, '<' . '?') !== false) { ob_start(); eval('?' . '>' . $text); $text = ob_get_contents(); ob_end_clean(); } return $text; }
Source: PHP Text Widget — Allow PHP In WordPress Text Widget – Binary Turf