phpwordpressmenuitemdynamic-links

Adding dynamic Link to menu Item in wordpress


I want to have 'Text only' in menu of my wordpress website without plugin.So how to set dynamic link to menu item in wordpress?


Solution

  • try this one

     add_filter('wp_nav_menu_items', 'menu_link', 10, 2);
    
        function menu_link($items, $args) {
    
                      if ($args->menu == 'footer'){
                        $items .= '<li class="copyright "><a href="' . get_permalink()."/?text=1" . '">Text Only</a></li>';
                        $items .= '<li class="copyright "><a href="' ."print.php"."?Page=".get_the_ID().'">Print Page</a></li>';
                      }
    
            return $items;
            // return $items1;
        }