Forums
Home / Themes and Templates / How to Display Dynamic link of page or post in a page Widget.
(@kuhashmi)
9 years, 5 months ago
I am using page widget
I know how to put simple HTML code in a widget so it can display on page, but i want to display dynamic link of Page or Post in a page widget.
Please tell me how i can do that.
(@stephencottontail)
WP’s default text widget doesn’t execute PHP by default, but there are a few options. You could try this code in your child theme’s functions.php:
functions.php
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; }
Another option would be to try a plugin that adds a PHP-enabled widget.