{"id":38,"date":"2017-05-03T10:30:07","date_gmt":"2017-05-03T10:30:07","guid":{"rendered":"http:\/\/webprow.com\/blog\/?p=38"},"modified":"2020-01-03T10:13:12","modified_gmt":"2020-01-03T10:13:12","slug":"php-wordpress-widgets","status":"publish","type":"post","link":"https:\/\/webprow.com\/blog\/php-wordpress-widgets\/","title":{"rendered":"PHP in wordpress widgets"},"content":{"rendered":"<p>In this how to write the php code in wordpress sidebar widgets<\/p>\n<p><strong>Step 1:<\/strong> Add the below code in <strong>functions.php<\/strong> to write the php code in wordpress widgets<\/p>\n<pre><code>add_filter('widget_text','execute_php',100);\r\nfunction execute_php($html)\r\n{\r\n if(strpos($html,\"&lt;\".\"?php\")!==false)\r\n{\r\n ob_start();\r\n eval(\"?\".\"&gt;\".$html);\r\n $html=ob_get_contents();\r\n ob_end_clean();\r\n }\r\n return $html;\r\n}<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Add the below code in text widgets \u00a0and check it<\/p>\n<pre><code>&lt;?php \r\necho \"Greate tutorial in webprow\"; \u00a0\r\n?&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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(&#8216;widget_text&#8217;,&#8217;execute_php&#8217;,100); function execute_php($html) { if(strpos($html,&#8221;&lt;&#8220;.&#8221;?php&#8221;)!==false) { ob_start(); eval(&#8220;?&#8221;.&#8221;&gt;&#8221;.$html); $html=ob_get_contents(); ob_end_clean(); } return $html; } Step 2: Add the below code in text widgets \u00a0and check it &lt;?php [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":151,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[13],"class_list":["post-38","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-widgets"],"_links":{"self":[{"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":1,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions\/120"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/media\/151"}],"wp:attachment":[{"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webprow.com\/blog\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}