WordPress.org

Ready to get started?Download WordPress

Ideas

Add exlude parameter to wp_nav_menu function

  1. Marventus
    Member

    12345

    Well, I guess the title says it all. I think this would make the function way more flexible. The 'exclude' parameter is present in other similar functions, such as wp_list_pages, wp_dropdown_categories, etc., so that will probably simplify its implementation.
    Cheers!

    Posted: 2 years ago #
  2. Ihor Vorotnov
    Member

    Why you need it? wp_nav_menu() outputs the menu created MANUALLY in Themes->Menus. If you don't need smth - just go and remove it from your menu. Or maybe I get your message wrong?

    Posted: 2 years ago #
  3. Marventus
    Member

    12345

    It could be useful if you want to reuse the menu in a different context but want to leave certain elements out. Another use that I see is conditional menus based on login status: if your menu is very long, instead of creating multiple ones, you could simply create one and use the exclude parameter to customize each visible version.
    Based on the function's code, it seems easy enough to implement and could potentially help users save a lot of time in blog customization.

    Posted: 2 years ago #
  4. Ihor Vorotnov
    Member

    If you are adding wp_nav_menu() in different contexts it seems like you are techie / theme developer, not an editor. And the case of this contextual exclusion is rather rare. wp_nav_menu() function allows you to call a custom walker (see reference). You can use it to achieve your task.

    The whole idea of wp_nav_menu() is to make creating CUSTOM menus and including them in your theme easy and without any additional coding. If you need another menu - create it, it takes only few minutes in menu editor.

    Posted: 2 years ago #
  5. Marventus
    Member

    12345
    If you are adding wp_nav_menu() in different contexts it seems like you are techie / theme developer

    I am not just thinking about me: I'm sure there are many non-developers out there that could find this feature useful.

    wp_nav_menu() function allows you to call a custom walker (see reference). You can use it to achieve your task.

    Walkers are for controlling HTML output. I use them all the time, but they seem highly overkill for the purposes described above, don't they?

    If you need another menu - create it, it takes only few minutes in menu editor.

    That may be your opinoin and/or way of going about it. However, I still think it would be nice to have the option to do it differently. THe argument is already included in other functions for which your same arguments could be applied. Yet, the argument is there. I am only asking to extend it to a very similar function.

    Posted: 2 years ago #
  6. Ihor Vorotnov
    Member

    The argument is already included in other functions for which your same arguments could be applied.

    But those are different functions. wp_nav_menu() has completely different concept behind it. And its concept is to use menu editor to build the EXACT menu you need.

    I'm not totally arguing against you proposal. I just think it will not work with the idea of building custom menus. It's a bit awkward if you manually create a menu and then somewhere on the site it does not look like it supposed to. It should be dead simple - create a menu, include it in your template and see it exactly how you configured it. That's what most of users expect it to be.

    Posted: 2 years ago #
  7. Ipstenu (Mika Epstein)
    Administrator

    if your menu is very long, instead of creating multiple ones, you could simply create one and use the exclude parameter to customize each visible version.

    Word of warning - Long menus can cause problems. This is a known issue in WP right now, and it's probably safer not to have one massive menu just yet.

    Posted: 2 years ago #
  8. Ihor Vorotnov
    Member

    You may call me whatever you want, but I really think if you have loooooong menus - there's something wrong with your content organization and structure. There are some cases when you need them to be long, e.g. on my veterinary portal there's a list of all pets and every of them has all breeds listed. Yes, they are massive. But in this case it would be odd to use wp_nav_menu to build it.

    Posted: 2 years ago #
  9. Ipstenu (Mika Epstein)
    Administrator

    Oh I agree that long menus are a bad idea. But to the specific matter of Marventus' idea:

    Another use that I see is conditional menus based on login status: if your menu is very long, instead of creating multiple ones, you could simply create one and use the exclude parameter to customize each visible version.

    There's a technical issue with that everyone should be aware of. Long menus break stuff :/

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    6 Votes
  • Status

    This idea is under consideration