Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

dropdown list

  • Hello, I want to create a dropdown list to include external links on the website. Here are two examples in photos.

    is it possible ?

    https://ibb.co/TY7xM8r
    https://ibb.co/27sbXTJ

  • Hi there,

    1. create a new menu with the parent menu item and its children at appearance > menus.

    2. assign this menu to secondary navigation.

    3. Use this PHP code to create a shortcode [secondary_navigation] for secondary navigation:

    add_shortcode( 'secondary_navigation', function() {
        ob_start();
    
        if ( function_exists( 'generate_secondary_navigation_position' ) ) {
            generate_secondary_navigation_position();
        }
    
        return ob_get_clean();
    } );

    4. You can use this shortcode on pages.

  • Thank you, but now the menu also displays at the top, how can I remove it ?

    I added the shortcode in the footer but I’m not really fond of the formatting. : exemple : https://ibb.co/26rhKP1

    I would rather display it this way :

    https://ibb.co/S7whzJX

    thabks you

  • Thank you, but now the menu also displays at the top, how can I remove it ?

    Go to customizer > layout > secondary navigation, set navigation location to no navigation.

    I would rather display it this way :

    It requires custom HTML and JavaScript, custom JS is out of our support scope, however, it’s quite simple, so try adding the below HTML and JS via a custom HTML block, and modify the HTML code based on your needs:

    <select id="myDropdown" onchange="navigate()">
      <option value="disabled selected">Select an option</option>
      <option value="https://google.com/">Option 1</option>
      <option value="https://x.com">Option 2</option>
      <option value="https://facebook.com">Option 3</option>
    </select>
    
    <script>
    function navigate() {
      var dropdown = document.getElementById("myDropdown");
      var selectedOption = dropdown.options[dropdown.selectedIndex];
      if (selectedOption.value) {
        window.location.href = selectedOption.value;
      }
    }
    </script>
  • Okay, so secondary navigation is no longer useful if I understand correctly?

  • Thank you Ying. For the first method, is it impossible to use it in list form with css ?

  • The first method should show the dropdown list with a prant menu item and multiple children menu items.

  • thabks

  • No Problem 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.