Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS WordPress: How do you make a navigation menu with select and options?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38282
    noahgelman
    Participant

    For mobile browsers, I want to give them a select dropdown that they can use to navigate. How can I make one?

    #103693
    TheDoc
    Member

    You should be able to simply create one with wp_list_pages and then make sure it only shows on mobile devices (I’m thinking media queries here).

    #103732
    noahgelman
    Participant

    Do I have to do anything special to get it to link?
    Do I just wrap the inside of the options with an anchor tag?
    How do I get to current page to be the default selection of the select box?

    I probably should have asked these at the beginning

    #103734
    noahgelman
    Participant

    Was able to get it

    $(document).ready(function() {
    $('#mobile-navigation option a').each(function() {
    var newValue = $(this).attr('href');
    $(this).parent().attr('value', newValue);

    });

    $('#mobile-navigation option').wrapAll('').children().contents().unwrap();
    $('#mobile-navigation option.current_page_item').attr('selected', 'selected');

    $("#mobile-navigation select").change(function() {
    window.location = $(this).find("option:selected").val();
    });


    $my_pages = wp_list_pages('depth=-1&echo=0&title_li=');
    $var1 = ' $var2 = ' $var3 = '';
    $var4 = '';
    $my_pages = str_replace($var1, $var2, $my_pages);
    $my_pages = str_replace($var3, $var4, $my_pages);
    echo $my_pages;
    ?>

    });
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.