Filter by more than 1 Taxonomy
-
Hi guys,
I’ve been banging my head against the wall for the last few hours trying to figure this out.
Basically I have a Custom Post Type called pennine-products which I have custom taxonomies to filter them to work like categories. All this is working fine when I use the plugin to call them back, the problem i’m having is I need to drill down even further using custom tags when trying to filter the posts depending on which section you are on.
It seems to me that I can only filter by the taxonomy product-cat or product-tag, which both work when I do this but it’s pulling back posts from other Taxonomies which I don’t want.
This is what I have so far
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?> <?php echo do_shortcode('[ajax_load_more data-posts-per-page="30" repeater="default" taxonomy="product_cat" taxonomy_terms="'.$term->slug.'" post_type="pennine-products" scroll="false" posts_per_page="3" button_label="Test"]'); ?> <?php $tag = get_queried_object()->slug; ?> <ul id="alm-filter-nav"> <li><a href="#" data-repeater="default" data-post-type="pennine-products" data-post-format="" data-category="" data-category-not-in="" data-tag="" data-tag-not-in="" data-taxonomy="product_cat" data-taxonomy-terms="<?php echo $term->slug ?>" data-taxonomy-operator="" data-meta-key="" data-meta-value="" data-meta-compare="" data-meta-relation="" data-meta-type="" data-year="" data-month="" data-day="" data-author="" data-post-in="" data-exclude="" data-search="" data-custom-args="" data-post-status="" data-order="DESC" data-orderby="date" data-offset="0" data-posts-per-page="30" data-lang="" data-scroll="false" data-scroll-distance="150" data-max-pages="5" data-pause-override="false" data-pause="false" data-button-label="Test" data-button-class="" data-destroy-after="" data-transition="slide" data-images-loaded="false">All Products</a></li> <li><a href="#" data-repeater="default" data-post-type="pennine-products" data-post-format="" data-category="" data-category-not-in="" data-tag="" data-tag-not-in="" data-taxonomy="product_tag" data-taxonomy-terms="key-stage-1" data-taxonomy-operator="" data-meta-key="" data-meta-value="" data-meta-compare="" data-meta-relation="" data-meta-type="" data-year="" data-month="" data-day="" data-author="" data-post-in="" data-exclude="" data-search="" data-custom-args="" data-post-status="" data-order="DESC" data-orderby="date" data-offset="0" data-posts-per-page="30" data-lang="" data-scroll="false" data-scroll-distance="150" data-max-pages="5" data-pause-override="false" data-pause="false" data-button-label="Test" data-button-class="" data-destroy-after="" data-transition="slide" data-images-loaded="false">Key Stage 1</a></li> </ul>
So the first li that filters products does exactly what I want it to do and keeps it within the relevant Taxonomy depending which page i’m on.
It’s when I try filter by the product-tag that it pulls in all posts that are tagged with Key-stage-1. I know that I need to try keep the filter relevant to the Taxonomy I want by getting the slug of the term, in this case sub-sub-category – I just don’t know where I put this to filter only in sub sub category.
Any help would be greatly appreciated.
Jason
- The topic ‘Filter by more than 1 Taxonomy’ is closed to new replies.