• 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.

Viewing 1 replies (of 1 total)
  • 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:

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘How to Display Dynamic link of page or post in a page Widget.’ is closed to new replies.