I have a site with a custom post type “projects” and two taxonomies “clients” and “mediums”. For the navigation I’m using a custom nav walker (that extends Walker_Nav_Menu). This all works very well and allows URLs such as:
/mediums/print/ (showing selection of print projects) /clients/clientA (showing selection of projects for clientA)
I have page templates for clients and mediums and templates taxonomy-clients.php and taxonomy-mediums.php. Ideally I would like to be able to have both those URLs and the nav continue to select an individual project through either client or medium e.g.
But after a very long search and searching way too many forums it seems this isn’t possible with Wordpress. Therefore I had to go with one path and chose:
To allow this to work and not just display all single projects post under /projects/project-A
I’m adding a filter hook to 'post_type_link' which modifies links to follow the full structure of /mediums/print/project-A and in the custom post type I’m using a placeholder %mediums% which is replaced by the relevant taxonomy term.
Again, this all works very well and now allows browsing by client or medium and selecting the project which then selects the full URL.
The problem I’m having is now the navigation doesn’t show any state for the single-projects.php template (nav is global and in the sidebar). I can see that this is most likely because although I’ve managed to get the URL and the links to work showing the full path WP and hence the walker don’t see the custom post type project as sitting below mediums/mediums-term and so doesn’t create the nav items required to show this state.
Does anyone know how I can get the walker to “see” this relationship?
I don’t think it’s unreasonable for users to want to selectively drill down to a project in this manner through project taxonomy and land on the project at the end of the tree rather than just jumping out to /projects/project-A with no reflection of the state in the navigation.