Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I have setup a custom post type 'products' and custom taxonomies / categories 'defence' 'law & enforcement' and 'Commercial'.

I have using the following conditional to set some specific css and the correct banner for a product:

<?php if (has_term( 'defence', 'productcat', $post->ID )) { ?>

This works fantastic if the product is in one category.

Here's my problem - i have products in multiple categories so i would like a conditional to see how they got to my product page:

I have a menu down the left side on taxonomy landing page and on product page, as an example lets say i have product 1 in all 3 taxonomies; down the left hand side there will be the 3 parent taxonomies with the product underneath each one as a child.

What i would like to do is have a conditional to set my custom css / banner depending on where the product on the left menu is clicked; ie if product 1 under 'Defense' is click i would like to display the 'Defense' banner, same goes if it is clicked under the other 2 taxonomies.

Hope this makes sense.

In all honesty i don't think this is possible and products with multiple taxonomies will just have to have the default css and a rotating banner with all taxonomies which it belongs too.

Your time and help with this is appreciated

Edit Just had a thought - if i can get the taxonomies to form part of my permalink ie domain.com/products/taxonomy/product i could use

$_SERVER['HTTP_HOST'] ==
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Ok, to work around this and do what i need to do i installed a plugin (Custom Post Type Permalinks by Toto_unit) to add custom post types and custom taxonomies to my permalink structure.

For my conditionals i'm using $_SERVER['HTTP_HOST'] == to check the current url.

Hopefully this helps someone else.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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