WordPress.org

Ready to get started?Download WordPress

Forums

need for something like 'get_ancestors_in_custom_menu()' (1 post)

  1. hedu64
    Member
    Posted 2 years ago #

    Dear forum,

    widgets in the primary sidebar of a new project need to be treated differently, depending on the sub-menu area where they are displayed.

    I created a custom menu with a mixture of (sub-)pages and categories (in the 2nd level of the custom menu).

    page 1
    - category 1
    - sub-page 1.1
    - sub-page 1.2

    In order to be able to display the right widgets in the right place I would need a function like get_ancestors_in_custom_menu(), which does not exist. This function would return the ID of the parent menu item, or an array of the IDs of the parent/ancestor items.

    WordPress provides some functions concerning the page or category hierarchy, but no function returning info about the hierarchy of a custom menu. As far as I can see.

    What could I use/do for getting the ID of the top level parent menu item within a custom menu?

    (I hope I could express what I mean :-)

    Thank you in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic