Change menu based on passed parameters (3 posts)

  1. vahost
    Posted 3 years ago #

    I need to be able to use a different menu depending on what parameter is being passed in the page's URL.

    For instance, assume the URL: http://www.mydomain.tld/my-page?m=3

    In this case, the parameter m=3 indicates that I want the page to use menu #3.

    Are there any plugins that can help with this?

    Is there a way to shortcode menus so that I can call them programmatically in a simple php script?

  2. vahost
    Posted 3 years ago #

    Can anyone help me with this?

  3. bcworkz
    Posted 3 years ago #

    I don't know if there's a plugin or not, and shortcodes would be over complicating things since the distinguishing information is in the URL parameter. Assuming the different menus have been registered and defined, you just need to do something on your page template like this:
    <?php wp_nav_menu( array( 'menu' => $_GET['m'] ) ); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic