Can we hide one event category from front page view..

To work around the lack of geo targeting and to avoid endless additional plugins to attempt to have a functioning geo calendar..
Can we hide one particular "event category" from front end view..

ie: users will need to enter their geo location so need to see it when adding their event..

However would prefer it did not showup on the single event view ..
Is this possible as its the only way we can use calendar shortcode as its limited to Event category only....

  • aristath
    • Recruit

    @be
    I suspect you could do this using the pre_get_posts filter, however I tried this on my own installation and was unable to make it work.
    I have notified the plugin developer about this issue, hopefully he'll be able to shed some light on this.
    Please keep in mind though that plugin developers have a lot of responsibilities so this might take a bit longer than a normal ticket.

    Cheers,
    Ari.

  • Vladislav
    • Dead Eye Dev

    Hello,

    I'm not sure I fully understood what you're after, but here's a bit of code that might help. This example will intercept loading the events with pre_get_posts filter and filter out categories with ID 7, 8 and 9:

    function drop_event_categories_pre_get_posts ($query) {
    	if (!($query instanceof WP_Query)) return $query;
    	if (Eab_EventModel::POST_TYPE !== $query->get('post_type')) return $query;
    	$query->set('tax_query', array(array(
    		'taxonomy' => 'eab_events_category',
    		'field' => 'id',
    		'terms' => array(7,8,9), // List of your category IDs
    		'operator' => 'NOT IN'
    	)));
    	return $query;
    }
    if (!is_admin()) add_filter('pre_get_posts', 'drop_event_categories_pre_get_posts');

    Effectively, this will prevent showing events from a category in your group-type views (calendars, archives and such). I apologise if I got something wrong and this is not what you're after; if that's the case, can you please elaborate a bit more on exactly what you need to happen?

  • be
    • WP Core Meltdown

    Thanks so much again -
    No that's not what we were after
    (we wanted to hide the cat tag at the bottom of each event not ignore that category)

    But we have just hidden all event category tags from pages and can live with this workaround..

    Thanks again

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.