• vahost

    (@vahost)


    I’m relatively new to creating filters, and consequently pretty weak in my understanding of how to create and use them. I’d appreciate a little guidance on how to create this one.

    In this case, I want to filter the URLs of the primary navigation menu on-the-fly when the app detects certain circumstances.

    My primary navigation items by default are not set with URLs that have a question mark and a myvar parameter at the end. They’re just standard permalinks with the primary domain and slug.

    But if the app detects a session variable that I’ve set elsewhere, I want to filter all the primary navigation items to add ?myvar=1 at the end.

    Can someone help me accomplish this?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If your template is using wp_nav_menu(), the filter ‘wp_nav_menu’ allows you to alter or add to the menu HTML that will be echoed out. If you require greater control, there’s several other filters and a walker function that can be used. Review the source code on wp-includes/nav-menu-template.php, around line 226 I believe.

Viewing 1 replies (of 1 total)
  • The topic ‘Modify primary nav URLs on-the-fly by adding parameter’ is closed to new replies.