lib/Post_Type_Query.php
public function pre_get_posts( $query ) {
		global $typenow;

		/**
		 * Check if we should modify the query.
		 *
		 * As a hint for for future condition updates: We can’t use $query->is_post_type_archive(),
		 * because some post_types have 'has_archive' set to false.
		 */
		if ( ! is_admin() ) {
			if (
				// Special case for post in a page_for_posts setting.
				( 'post' === $this->post_type && ! $query->is_home() )
				// All other post types.
				|| ( 'post' !== $this->post_type && $this->post_type !== $query->get( 'post_type' ) )
			) {
				return;
			}
		} elseif ( ! $query->is_main_query() || $typenow !== $this->post_type ) {
			return;
		}

		// Differ between frontend and backend queries.
		$query_args = $this->query_args[ is_admin() ? 'backend' : 'frontend' ];

		if ( empty( $query_args ) ) {
			return;
		}

		// Set query args.
		foreach ( $query_args as $key => $arg ) {
			$query->set( $key, $arg );
		}
	}
public function pre_get_posts( $query ) {
		global $typenow;

		/**
		 * Check if we should modify the query.
		 *
		 * As a hint for for future condition updates: We can’t use $query->is_post_type_archive(),
		 * because some post_types have 'has_archive' set to false.
		 */
		if ( ! is_admin() ) {
			if (
				// Special case for post in a page_for_posts setting.
				( 'post' === $this->post_type && ! $query->is_home() )
				// All other post types.
				|| ( 'post' !== $this->post_type && $this->post_type !== $query->get( 'post_type' ) )
			) {
				return;
			}
		} elseif ( ! $query->is_main_query() || $typenow !== $this->post_type ) {
			return;
		}

		// Differ between frontend and backend queries.
		$query_args = $this->query_args[ is_admin() ? 'backend' : 'frontend' ];

		if ( empty( $query_args ) ) {
			return;
		}

		// Set query args.
		foreach ( $query_args as $key => $arg ) {
			$query->set( $key, $arg );
		}
	}
public function pre_get_posts ( $ query ) { global $ typenow ; /**
		 * Check if we should modify the query.
		 *
		 * As a hint for for future condition updates: We can’t use $query->is_post_type_archive(),
		 * because some post_types have 'has_archive' set to false.
		 */ if ( ! is_admin ( ) ) { if ( // Special case for post in a page_for_posts setting. ( 'post' === $ this -> post_type && ! $ query -> is_home ( ) ) // All other post types. || ( 'post' !== $ this -> post_type && $ this -> post_type !== $ query -> get ( 'post_type' ) ) ) { return ; } } elseif ( ! $ query -> is_main_query ( ) || $ typenow !== $ this -> post_type ) { return ; } // Differ between frontend and backend queries. $ query_args = $ this -> query_args [ is_admin ( ) ? 'backend' : 'frontend' ] ; if ( empty ( $ query_args ) ) { return ; } // Set query args. foreach ( $ query_args as $ key => $ arg ) { $ query -> set ( $ key , $ arg ) ; } }
Alters the query.

@param \WP_Query $query A WP_Query object.
Alters the query .