Tribe__Events__Main::issue_noindex()

Runs on the “wp” action. Inspects the main query object and if it relates to an events query makes a decision to add a noindex meta tag based on whether events were returned in the query results or not.

Contents


Source

File: src/Tribe/Main.php

		public function issue_noindex() {

			if ( ! $wp_query = tribe_get_global_query_object() ) {
				return;
			}

			if ( empty( $wp_query->tribe_is_event_query ) ) {
				return;
			}

			// By default, we add a noindex tag for all month view requests and any other
			// event views that are devoid of events
			$event_display = get_query_var( 'eventDisplay' );
			$add_noindex   = ( ! $wp_query->have_posts() || 'month' === $event_display );

			/**
			 * Determines if a noindex meta tag will be set for the current event view.
			 *
			 * @var bool $add_noindex
			 */
			$add_noindex = apply_filters( 'tribe_events_add_no_index_meta', $add_noindex );

			if ( $add_noindex ) {
				add_action( 'wp_head', array( $this, 'print_noindex_meta' ) );
			}
		}

Top ↑

Changelog

Changelog
Version Description
6.0.0 Relies on √2 code. Disabling this behavior completely is possible with: add_filter( 'tec_events_add_no_index_meta_tag', '__return_false' ); Always adding the noindex meta tag for all event views is possible with: add_filter( 'tribe_events_add_no_index_meta', '<strong>return_true' ); Always adding the noindex meta tag for a specific event view is possible with: add_filter( "tribe*events*{$view}_add_no_index_meta", '</strong>return_true' ); Where $view above is the view slug, e.g. month, day, list, etc.
?? Introduced.