Can I query custom post types by the taxonomy of the active page?
-
I work for a company that has a very specific request and I’d love some advice on how to kick off this particular query – I think I’ve bitten off more than I can chew but would appreciate any help!
I need to be able to query in a widget, custom post types by the taxonomy of the active page with results categorised by post type.
e.g.
All our company’s products have their own page and a custom taxonomy of “product-name x“
We also have accessories, technical information, news items and brochures available for each of these product types. These are custom post types (‘news’ , ‘brochures’ , ‘accessories’).
So, for product page “machine x”, I’d like a widget on the sidebar that picks up on the taxonomy “machine x” and displays a list of custom posts types that are all tagged “machine x” and when you click on one of these links in the list, it lists all the custom posts within that type that are marked “machine x”.
Is this possible? I’ve managed to get a clunky version of what I want using lists and shortcodes, but if there’s a way to query custom post types by the taxonomy of the active page, then this would be much smoother.
I’ve linked here to an image showing what I mean
Fingers crossed someone’s done something similar? Any help or even just a pointer in the right direction would be seriously appreciated!!
- The topic ‘Can I query custom post types by the taxonomy of the active page?’ is closed to new replies.