WordPress.org

Ready to get started?Download WordPress

Ideas

Automatic building sublevels menus using subcategories.

  1. montecristo2
    Member

    Hello, it seems that when building the top-level custom menu from categories entries, the nested subcategories hierarchy is not automatically added.
    Is there a method to avoid adding manually all subcategories and reordering them by drag-and-drop when we publish a category menu entry?
    And, is it possible to automaticaly add/reorder an accordingly submenu entry when a subcategory is added to a category? Like the checkbox "Automatically add new top-level pages" but for subcategories.
    I try to look for a solution in the documentation, forums and pluggins but without any result. But maybe a solution already exists?
    I am a newbie with WordPress, so after more researches, maybe I have understood the reason: because it seems that I can't reorder categories (without hacking category ID in database), so I can't also have an "arbitrary" order displayed in category widget (not alphabetic, or date, or ID), so it's the only method to allow "arbitrary" ordered entries in the top menu...
    Sorry for my poor english, hope it's enough clear.

    Posted: 3 years ago #
  2. KuroTsuto
    Member

    12345

    I concur. Self-populating custom-menu items are a sorely needed feature. In my particular case, I would like to see the ability to add a category or custom-post-type item to the menu and have it self-populate with its children categories or posts belonging to that custom-post-type.

    This idea relates to Trac Ticket #14331. In regards to specific functionality, I don't believe it necessary that such auto-populating menu-items should actually add all of their children/posts into the database as menu items, but should rather provide an interface in the dropdown menu-item options allowing you to list multiple post/category IDs to exclude, not dissimilar to the default 'Pages' widget.

    Currently the only ways in which I have figured out to achieve such functionality require that one mix a selection of custom menus and widgets, write a new Nav_Walker of discouraging complexity, or manually modify the menu-items either while they're still in an array or after they're returned as a string.

    Posted: 3 years ago #
  3. Old Photos Specialist
    Member

    12345

    +1 for the suggestion. Somewhat automatic mapping of subcategories to submenus that allows tweaking to some extent will be a nice time-saver for content-rich sites. However, this seems to me like a non-trivial thing to implement and the amount of tweaking it will allow would be trade-off that will need to be carefully considered so that the feature suits both power users and not so tech savvy users alike.

    Anyhow, this will definitely be a nice to have functionality.

    Posted: 3 years ago #
  4. JoshLovesIt
    Member

    12345

    I also would love to see this functionality added to the WordPress custom menus! I agree that you should be able to automatically add subcategories, but exclude undesired subcategories with post/category IDs.

    Posted: 3 years ago #
  5. KuroTsuto
    Member

    12345

    Hey all - I recently had a project for a client in which I needed to populate the menu with about 970 individual entries. Obviously constructing such a menu by hand was out of the question.

    Digging into the core, I found that there were absolutely no hooks where I needed them to be. In the end, I managed to throw together a plugin based on the core menu code that allows you to populate a sub-menu with items as selected with standard WP_Query parameters. Currently, enabling the functionality on an item requires that you create a custom menu item, then find it in the database and add about four fields or so.

    Specifically, you call the plugin's version of wp_nav_menu instead of the default one. The difference is that the plugin's version is watching for a new type of menu item. When it encounters a menu item of said type, it executes a query based on the query parameters attached to that item, generates fake menu item objects for every returned post, then inserts them into the original menu item object list before sending it off to the function that generates the actual markup.

    I tried implementing a few different forms of auto-caching, as well. JSON files, database entries, serialized text files and WordPress Options, all of which would check for changes and re-gen if necessary, but all of them really just seemed to slow things down rather than speed 'em up. Ideally, the system would cache the generated markup rather than the menu item objects themselves. Even with 970 items, though, there doesn't seem to be too big of a performance hit when caching is turned off.

    The thing is essentially a massively fat hack, though. It's pretty much the equivalent of me making a copy of the core code then stumbling around half-blind with a broadsword smashing random chunks until it worked. One notable side-effect is that using it totally messes up the WP menu-order numbering (not that I really ever found much use for it though).

    If there's enough interest, I'll set about polishing it up and throwing together an admin screen for the thing - or at least write a blog post on the topic sometime soon.

    I don't think I'll be submitting it as a patch to Trac anytime soon, though - like I said, thing's a mess! O.o

    Posted: 3 years ago #
  6. snomo
    Member

    +1 for this capability!!!

    Posted: 2 years ago #
  7. ctdev
    Member

    12345

    Great idea! Now how do we handle this currently?

    Posted: 1 year ago #
  8. Ellen Hopkins
    Member

    It would be great if this one would get implemented, I'm in.

    Posted: 7 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    18 Votes
  • Status

    This is plugin territory