I’m making a website for my friend’s business, he sells some electrical equipment. He wants to list the manufacturers he sells and the types of products. For example, there is 50 manufacturers and 20 product categories.
Using GD CPT Tools, I added two taxonomies, one called ‘product’ and another called ‘manufacturer’. Also, I set up two categories by the same name. When we make a new entry for a manufacturer, we add the manufacturer name to the taxonomy list, select the ‘manufacturer’ category, and then add the types of products that manufacturer sells in the product taxonomy. Each manufacturer and product has only one associated post, but products have multiple manufacturers tagged in the taxonomy list, because there are many manufacturers of any given product.
Now I want to be able to load a post of a given product type and see the manufacturers associated with that product (I thought that was the point of using taxonomies, that is to be able to organise posts easily). Also when I load a post of a given manufacturer, I want to see the product types they are associated with.
Above are links to the code I tried by MichaelH, but I can’t get it to work. Am I on the right path? Can someone help me out, perhaps there is a plugin for this already? I searched but have no solution yet.
I commented out the line, seemed unnecessary to me:
‘post__not_in’ => array( $post->ID ),
If I set these lines to:
$taxonomy = ‘product’;
$param_type = ‘category__in’;
and visit an entry for a manufacturer, I am properly returned the product taxonomy entries associated with that manufacturer.
If I change this line to:
$taxonomy = ‘manufacturer’;
and visit an entry for a manufacturer, I am properly returned the one taxonomy entry for the manufacturer. But, if I visit an entry of a product type, I am only returned ONE manufacturer instead of all the ones associated with that product type. What am I doing wrong?
Might I need to use a function like ‘is_object_in_taxonomy’ instead of all this code? I’ve just started investigating that, it seems simpler.
- The topic ‘Help me display list of taxonomy tags associated with a post’ is closed to new replies.