Recently we were working on an extensive brochure-style site with a “view only” catalogue area.
Part of the way through the build the requirement became apparent that certain products were going to feature in multiple terms of our navigational taxonomy. Not typically a problem, but some ancillary data on the page was to be determined by which term they had navigated from. A quick fix solution would be to query string the values in the archive and pull them through on the single page, but this would leave a really ungraceful, and SEO-unfriendly link structure.
So we first applied some WP_Rewrite Rules to create a more graceful structure, and then opted to get the navigational structure by tapping in to the request string in the global $wp object.
To do this we created a function that converts this URL into an array and then drops the current page/post slug; grabbing the previous value (which is the deepest navigational slug) and performing the get_term_by to return a term object.
If you’ve any use for this function, you can grab the gist here.