Home › Forums › Calendar Products › Filter Bar › Hiding unnamed/blank venues & organizers from filter bar
- This topic has 8 replies, 3 voices, and was last updated 9 years, 9 months ago by
William.
-
AuthorPosts
-
July 6, 2016 at 7:21 pm #1136369
William
ParticipantHello!
It looks like we’re going to have a fair number of empty venue and organizer name fields, with the remaining fields in each used for location and contact info. I already figured out how to handle that on the single-event view page, but I just noticed I have a bunch of blanks under Venue and Organizer, and “Unnamed Venue” under Venue when searching with the filter bar. I’d like for those not to be included since they’re not needed for searching anyway, and don’t look very pretty.
I replicated the issue on a clean install with the twentysixteen theme. It happens when you skip venue or organizer name and fill in other info beneath them (address and contact info).
Attached are screenshots of what it looks like with the dropdown menu. The same thing happens with autocomplete and radio buttons.
Hoping you guys can help me out. Thanks!
July 7, 2016 at 2:06 pm #1136915George
ParticipantHey @William,
Thanks for reporting this. I took a look through our code and, unfortunately, there is not much by way of filters or actions to “properly” filter out these empty-titled venues and organizers.
I am going to propose the introduction of such filters for some future release, but in the meantime, I wrote a bit of JavaScript for you that should help pull this off. It’s not ideal to do stuff like this in this way, but it should help for the time being.
To use my snippet, simply copy and paste the contents of this Gist into your theme’s functions.php file ? https://git.io/vKYEP
I hope this helps!
GeorgeJuly 8, 2016 at 12:10 pm #1137488William
ParticipantGreat, thanks! Works perfectly for the checkbox style menus.
So this could be marked resolved but for one more question- I was using the dropdown menu before. Would it be possible to modify this snippet to work for that style too? If not, no problem, this solves the main problem.
-
This reply was modified 9 years, 9 months ago by
William.
July 8, 2016 at 2:19 pm #1137565George
ParticipantHey @William,
I’m sorry for my mistake here, but there actually IS a filter we can use to keep empty values out of the filter lists!
Try replacing the other snippet with this one:
function tribe_remove_empty_values_from_organzier_venue_filters( $values, $slug ) {
if ( 'organizers' === $slug || 'venues' === $slug ) {
foreach ( $values as $key => $value ) {
if ( empty( $value['name'] ) ) {
unset( $values[ $key ] );
}
}
}return $values;
}add_filter( 'tribe_events_filter_values', 'tribe_remove_empty_values_from_organzier_venue_filters', 10, 2 );
The great thing about this is that it should ensure empty values are removed in ALL filter types—drop-down or otherwise! 😀
— George
July 9, 2016 at 9:16 am #1137768William
ParticipantCool! That works great for the empty values. Can it also be employed to not show the “Unnamed Venue” entries?
July 9, 2016 at 9:32 am #1137771George
ParticipantOops! Sorry for forgetting that bit.
Yes, you should be able to exclude those values too by changing this line of code:
if ( empty( $value['name'] ) ) {To this:
if ( empty( $value['name'] ) || 'Unnamed Venue' == $value['name'] || 'Unnamed Organizer' == $value['name'] ) {— George
July 9, 2016 at 10:26 am #1137806William
ParticipantAwesome, looks great! Thanks for hanging with me for a few rounds.
July 11, 2016 at 9:00 am #1138154George
ParticipantLikewise! 😀
-
This reply was modified 9 years, 9 months ago by
-
AuthorPosts
- The topic ‘Hiding unnamed/blank venues & organizers from filter bar’ is closed to new replies.
