• Resolved almightymax

    (@almightymax)


    Hello guys,
    I develop a theme which display three diffrent menus in one block.
    To do so I use $_GET to switch between the men
    u, Example:

    <a href="?navopt=main">Main</a><a href="?navopt=brand">Brands</a><a href="?navopt=filter">Filter</a>
                <?php
                $nav = ( $_GET['navopt'] ) ? $_GET['navopt'] : main ;
                wp_nav_menu( array(
                    'theme_location' => $nav,
                    'container' => 'false'
                    ) );
                echo $nav; ?>

    *The final echo is just for debugging.

    But when I use get_query_var(), it doesnt work.
    (I replaced the $_GET[‘navopt’] with get_query_var(‘navopt’).

Viewing 2 replies - 1 through 2 (of 2 total)
  • To use get_query_var() you must first ensure your query var is recognised by WordPress as follows:

    add_filter('query_vars', 'register_navopt_query_var' );
    function register_navopt_query_var( $qvars ) {
       $qvars[] = 'navopt';
       return $qvars;
    }
    Thread Starter almightymax

    (@almightymax)

    Tnx! Solved the issue

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘cant get vars from url’ is closed to new replies.