tribe_is_events_home()

Test if we are on the home of events either if is set to frontpage or the default /events page.

Utility function to test if we are on the home of events, it makes a test in cases when the page is set to be on the frontpage of the site and if the User is on that page is on the homepage or if the User is on the events page where the eventDisplay is set to default.

Also consider this might not work as expected inside of Ajax Calls as this one is fired on initial loading of the page so be aware of unexpected results via Ajax calls.


Return

(bool)


Top ↑

Source

File: src/functions/template-tags/general.php

	function tribe_is_events_home() {

		$wp_query = tribe_get_global_query_object();

		if ( tribe_is_events_front_page() ) {
			return true;
		}

		$events_as_front_page = tribe_get_option( 'front_page_event_archive', false );
		// If the readme option does not has an event page as front page and if id the 'default' view on the main query
		// as is going to set to 'default' when is loading the root of events/ rewrite rule also makes sure is not on
		// a taxonomy or a tag.
		if (
			! $events_as_front_page
			&& $wp_query->is_main_query()
			&& $wp_query->tribe_is_event // Make sure following conditionals operate only on events
			&& ( isset( $wp_query->query['eventDisplay'] ) && 'default' === $wp_query->query['eventDisplay'] )
			&& is_post_type_archive()
			&& ! is_tax()
			&& ! is_tag()
		) {
			return true;
		}

		// No condition was true so is not on home of events.
		return false;
	}

Top ↑

Changelog

Changelog
Version Description
4.6.9 Introduced.