0

I'm using a "location" taxonomy to show the same website for 4 different locations. Each of them will have the same categories which I want to display in a menu.

Is there anyway to create the same menu to show posts filtered by category but which also takes into account the current taxonomy the user is in? Can I do it directly using the wordpress panel or would I need to create a specific theme for it?

Basically, the site would have an index with 4 options, for example:

  • London
  • Cambridge
  • Manchester
  • Briton

Once the user click in any of them, a new menu will appear:

  • Cars
  • Tvs
  • Trains
  • Ships

So if I click in first in "Briton" and then in "Cars", the page should only show the posts with the category "cars" which are also inside the taxonomy "Briton".

1

1 Answer 1

1
+50

How about creating those categories Cars, Tvs, Trains and Ships as sub categories of locations?

Then you could have a navigation menu containing parent categories i.e Briton, Manchester etc.

Once a parent category is navigated to you could have a menu that uses the get_terms() function with the parent argument set to the current location term ID that lists all sub categories of the current location. Something like this.

$tax = get_query_var('taxonomy' );
$current_location_id = get_term_by( 'slug', get_query_var( 'term' ), $tax ); 
$terms = get_terms( $tax, array(
    'parent' => $current_location_id
) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.