Here is an example structure of some content:
Parent A
-- Child A
-- Child B
Parent B
-- Child C
-- Child D
Parent A
should link to the content of Child A
and Parent B
should link to the content of Child C
. Other than that, I’m not sure if this is something that should be managed completely by “menus” in wordpress, or if it should be a Parent A
page with children pages. The only problem there is that Parent A
isn’t really content, just a link to Child A
.
If you need a real world example, it would be something like this:
Main Navigation:
Home, Company, Products, Contact
Company
-- About Us
-- News
-- Careers
In this instance, there is not really a “Company” page, but the “Company” is really a link to “About Us”.
If “Child A” or “Child B” is selected, in the sidebar this section of the navigation should appear:
Parent A
-- Child A
-- Child B
If “Child C” or “Child D” is selected, in the sidebar this section of the navigation should appear:
Parent B
-- Child C
-- Child D
Hopefully this question makes sense. I’m trying to understand how to access the navigation items individually. I can’t even find useful methods (closest I’ve come is get_nav_menu_item_children
). How should this be organized and what methods does wordpress contain that can help me achieve it?
3 ideas:
page.php
– test if children for this page exist and usewp_redirect()
to skip this page and redirect to the children automatically.The last one is probably the most sophisticated one. If you are having many sites it may pay of, otherwise just stick with the custom menu. Drawback is of course, that you are forced to use this scheme on all pages.
Creating a custom page template e.g.
redirect.php
and only applying the logic of 3. there would give you the option to use the children-redirect only on chosen pages.Edit: based on kaisers input this is how a good redirect could look like:
[untested!]