• I have added 2 or three custom links to a menu that appears as inside the submenu drop down. I added them to link to specific sections using #div_id_name terms.Now I have to enter the complete url in order to link them to specific pages. Is there a function that would automatically link them to the parent page so that I just need to enter the # part?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Are you referring to the WP Nav Menu accessed under Appearance in the Admin menu? Using the Links widget?

    If so, the functionality you desire will not work. You cannot enter code into the Links widget. You’d need to create a custom widget for that, and you will have difficulty determining what the parent page is when the widget is inserted in the menu structure. The widgets know where they fall in the menu hierarchy, but not what content parent widgets link to. I’m not saying it’s impossible, just difficult.

    A more plausible approach would be to use one of the wp_nav_menu() hooks or a custom walker to pick up on solo #div-id links and determine the parent and add it to the output html. Unlike the widgets, nav menu objects can likely determine their parent’s URL.

    IMO, the amount of coding involved is out of proportion to simply determining the parent URL manually when inserting the Links widget. YMMV

Viewing 1 replies (of 1 total)
  • The topic ‘Add default location to all Custom Menu Links’ is closed to new replies.