WordPress.org

Ready to get started?Download WordPress

Forums

wp_nav_menu - not working with # and ? in URL (1 post)

  1. chaddix
    Member
    Posted 3 years ago #

    The theme of my website inserts a navigation bar on the left-hand side of each page - the code to accomplish this is at the end of this message. This works great - except when a URL is extended with a hash or question mark (pagename/#foo or pagename/?foo).

    I've done some experimenting to see when it will work and not work:

    1. Works - A hyperlink contains pagename/#foo. When this hyperlink is clicked, the page is loaded with a URL of pagename/#foo and the navigation bar appears.
    2. Does not Work - A page is loaded by typing pagename/#foo as the URL. The navigation bar is gone.
    3. Does not Work - A page is reloaded with pagename/#foo as the URL. The navigation bar is gone.
    4. Does not Work - A page is loaded by typing pagename/?foo, reloaded with a URL of pagename/?foo, or loaded from a hyperlink on another page linking to pagename/?foo.

    I'm very new to WordPress - this website was not designed by me, but I will be charged with maintaining and adding to it, so I'm here to learn. Much thanks in advance to anyone who can help.

    Page Template

    <div id="left_col">
    <?php get_sidebar('medical'); ?>
    </div>

    Page Template Calls This

    <?php
    // use wp_list_pages to display parent and all child pages all generations (a tree with parent)
    wp_nav_menu( array( 'theme_location' => 'medical', 'sort_column' => 'menu_order', 'container_id' => 'left_nav') );
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic