Hiding unnamed/blank venues & organizers from filter bar

Home Forums Calendar Products Filter Bar Hiding unnamed/blank venues & organizers from filter bar

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1136369
    William
    Participant

    Hello!

    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!

    #1136915
    George
    Participant

    Hey @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!
    George

    #1137488
    William
    Participant

    Great, 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 7 years, 9 months ago by William.
    #1137565
    George
    Participant

    Hey @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

    #1137768
    William
    Participant

    Cool! That works great for the empty values. Can it also be employed to not show the “Unnamed Venue” entries?

    #1137771
    George
    Participant

    Oops! 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

    #1137806
    William
    Participant

    Awesome, looks great! Thanks for hanging with me for a few rounds.

    #1138154
    George
    Participant

    Likewise! 😀

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Hiding unnamed/blank venues & organizers from filter bar’ is closed to new replies.