Two Filters, One Grid
-
Hi,
Thanks for creating this plugin, I couldn’t find anything else like it. What I’ve used it for works well, but what I’d like to do (and I’ll happily purchase the premium version) is:
1) Have two separated isotope filters above the same grid: one on the left (or top) with Parent A subcategories, another on the right (or bottom) with Parent B subcategories. I just want the two to be visually separated; I don’t want them to function separately.
2) I’d like the multiple selection to be an AND selector, not an OR selector. I.e., so a front-end user can filter to only show posts that meet BOTH Parent A Subcategory 1 AND Parent B Subcategory 4 criteria, for instance, rather than posts that fall into either of those categories. I hope this makes sense.
Thanks!
-
Hi there,
Thanks!
1) At the moment it’s not possible to have 2 separate filters for the same grid. I’ll add it to our idea list.
2) The default behaviour for filters from different taxonomies is already AND. Within the same taxonomy (or category) you can enable “Multiselect” and then have the option for AND or OR behaviour.
Kind regards,
BrechtThank Brecht. I purchased the premium version and the multi-selection feature does exactly what I want.
Another question relating to my first: is there any way to show the filter labels in a custom order? So that I could list all Category 1 labels and then all Category 2?
Thanks again — great plugin.
Good to hear the multi-selection works.
To change the order you have to use some custom code at the moment. You’d have to add something like this to your theme’s functions.php file:
function wpupg_change_terms_order( $filter_terms_order, $grid ) { if( $grid->slug() == ‘your-grid-slug' ) { $filter_terms_order = array( ’term-1', ’another-term', ‘yet-another-one' ); } return $filter_terms_order; } add_filter( 'wpupg_grid_cache_filter_isotope_term_order', 'wpupg_change_terms_order', 10, 2 );Make sure to replace the grid and term slugs to whatever you’re using.
Hi Brecht,
Thanks, but it’s not working for me. Must be doing something wrong. Here’s what I’m using:
function wpupg_change_terms_order( $filter_terms_order, $grid ) { if( $grid->slug() == ‘448' ) { $filter_terms_order = array( ( ’all', ’fund i & ii', ‘fund iii', 'fund iv', 'fund viii', 'cuii', 'cmmt', 'infrastructure', 'austin', 'california', chicago', 'dallas', 'dc area', 'hollywood-west hollywood', 'las vegas', 'los angeles', 'new york', 'oakland', 'sacramento', 'texas', 'hotel', 'mixed use', 'office', 'parking', 'residential', 'retail') } return $filter_terms_order; } add_filter( 'wpupg_grid_cache_filter_isotope_term_order', 'wpupg_change_terms_order', 10, 2 );Could you give me a link to your grid? I’ll take a look.
Brecht
The site’s still in development stage on a private server, so unfortunately I can’t give you a link.
I’m not exactly expert in PHP, so I’m wondering if there’s a mistake in my code. I pasted it at the bottom of my child theme functions.php file, and it crashes my site (easily fixed by erasing it from the file).
Oh, I didn’t realised it crashed the site.
The problem is that you are using the wrong apostrophe’s. It should be a plain ‘ not ‘ (like before 488) or ’ (like before all). There is also a ‘ missing before chicago.
Something like this:
function wpupg_change_terms_order( $filter_terms_order, $grid ) { if( $grid->slug() == '448' ) { $filter_terms_order = array( ( 'all', 'fund i & ii', 'fund iii', 'fund iv', 'fund viii', 'cuii', 'cmmt', 'infrastructure', 'austin', 'california', 'chicago', 'dallas', 'dc area', 'hollywood-west hollywood', 'las vegas', 'los angeles', 'new york', 'oakland', 'sacramento', 'texas', 'hotel', 'mixed use', 'office', 'parking', 'residential', 'retail') } return $filter_terms_order; } add_filter( 'wpupg_grid_cache_filter_isotope_term_order', 'wpupg_change_terms_order', 10, 2 );You should also use the term slugs. There are no spaces in slugs, so ‘new york’ should probably be ‘new-york’.
Brecht
Sorry for the newbie error (typed up the terms in MS Word like a fool…).
Still though, no change. Here’s what I’m using now, and I still get an error message saying the admin page isn’t working, and my site crashes:
function wpupg_change_terms_order( $filter_terms_order, $grid ) { if( $grid->slug() == '448' ) { $filter_terms_order = array( ( 'all', 'fund-i-ii', 'fund-iii', 'fund-iv', 'fund-viii', 'cmmt', 'california', 'chicago', 'dallas', 'dc-area', 'hollywood-west-hollywood', 'las-vegas', 'los-angeles', 'new-york', 'oakland', 'sacramento', 'texas', 'hotel', 'mixed-use', 'office', 'parking', 'residential', 'retail') } return $filter_terms_order; } add_filter( 'wpupg_grid_cache_filter_isotope_term_order', 'wpupg_change_terms_order', 10, 2 );I’m curious — what does the ’10, 2′ refer to? Is that a variable I need to modify?
Sorry, looks like I copied and pasted a few mistakes as well. A double “(” at the start of the array and no “;” at the end. Try this:
function wpupg_change_terms_order( $filter_terms_order, $grid ) { if( $grid->slug() == '448' ) { $filter_terms_order = array( 'all', 'fund-i-ii', 'fund-iii', 'fund-iv', 'fund-viii', 'cmmt', 'california', 'chicago', 'dallas', 'dc-area', 'hollywood-west-hollywood', 'las-vegas', 'los-angeles', 'new-york', 'oakland', 'sacramento', 'texas', 'hotel', 'mixed-use', 'office', 'parking', 'residential', 'retail' ); } return $filter_terms_order; } add_filter( 'wpupg_grid_cache_filter_isotope_term_order', 'wpupg_change_terms_order', 10, 2 );The “10, 2” should not be changed.
Brecht
A-ha, works beautifully! Thanks Brecht!
And btw, I want to say again what a great plugin this is, with nothing else like it that I could find.
Good to hear that works!
Just let me know if you need anything else.Brecht
One problem of giving such great support is…people will use it!
Sorry, one more question which would actually accomplish what I initially set out to do — create two (visibly) separate filters for a single grid (using a single filter).
Is there any way to force a line break in the PHP code? For instance, between ‘cmmt’ and ‘california’? These are separate categories, so if I put them in separate lines/rows, it would make them appear separate. If it’s not an easy fix, no problem, but if so, it would be very useful.
Thanks again!
I’m here to help, so definitely make use of that support!
Try adding the following code as well:
function wpupg_filter_split( $output, $grid ) { $break_after = 'Tag Name'; return str_replace( $break_after . '</div>', $break_after . '</div><br/>', $output ); } add_filter( 'wpupg_filter_shortcode', 'wpupg_filter_split', 10, 2 );Make sure to replace “Tag Name” with the name of the tag as shown to the visitors that you want to break after.
Brecht
Works like a charm! So that’s a perfect way to separate out a single filter into categories. Really great — thanks Brecht!
So, I’m trying to do basically this exact thing. Except, I have a lot more options in each filter. Is there any way around hard coding them all in? Mine are 2 different taxonomies, so could I maybe order by taxonomy?
The topic ‘Two Filters, One Grid’ is closed to new replies.