init.php
public function modify_query( $query ) {
		$is_users = 'pre_get_users' === current_filter();

		if ( $is_users ) {
			// This is not working until we fix the user query bit.
		} else {
			$types = $_POST['search_types'];
			$types = is_array( $types ) ? array_map( 'esc_attr', $types ) : esc_attr( $types );
			$query->set( 'post_type', $types );
		}

		if ( ! empty( $_POST['retrieved'] ) && is_array( $_POST['retrieved'] ) ) {
			// Exclude posts/users already existing.
			$ids = array_map( 'absint', $_POST['retrieved'] );

			if ( ! empty( $_POST['exclude'] ) && is_array( $_POST['exclude'] ) ) {
				// Exclude the post that we're looking at.
				$exclude = array_map( 'absint', $_POST['exclude'] );
				$ids = array_merge( $ids, $exclude );
			}

			$query->set( $is_users ? 'exclude' : 'post__not_in', $ids );
		}

		$this->maybe_callback( $query, $_POST );
	}
public function modify_query( $query ) {
		$is_users = 'pre_get_users' === current_filter();

		if ( $is_users ) {
			// This is not working until we fix the user query bit.
		} else {
			$types = $_POST['search_types'];
			$types = is_array( $types ) ? array_map( 'esc_attr', $types ) : esc_attr( $types );
			$query->set( 'post_type', $types );
		}

		if ( ! empty( $_POST['retrieved'] ) && is_array( $_POST['retrieved'] ) ) {
			// Exclude posts/users already existing.
			$ids = array_map( 'absint', $_POST['retrieved'] );

			if ( ! empty( $_POST['exclude'] ) && is_array( $_POST['exclude'] ) ) {
				// Exclude the post that we're looking at.
				$exclude = array_map( 'absint', $_POST['exclude'] );
				$ids = array_merge( $ids, $exclude );
			}

			$query->set( $is_users ? 'exclude' : 'post__not_in', $ids );
		}

		$this->maybe_callback( $query, $_POST );
	}
public function modify_query ( $ query ) { $ is_users = 'pre_get_users' === current_filter ( ) ; if ( $ is_users ) { // This is not working until we fix the user query bit. } else { $ types = $ _POST [ 'search_types' ] ; $ types = is_array ( $ types ) ? array_map ( 'esc_attr' , $ types ) : esc_attr ( $ types ) ; $ query -> set ( 'post_type' , $ types ) ; } if ( ! empty ( $ _POST [ 'retrieved' ] ) && is_array ( $ _POST [ 'retrieved' ] ) ) { // Exclude posts/users already existing. $ ids = array_map ( 'absint' , $ _POST [ 'retrieved' ] ) ; if ( ! empty ( $ _POST [ 'exclude' ] ) && is_array ( $ _POST [ 'exclude' ] ) ) { // Exclude the post that we're looking at. $ exclude = array_map ( 'absint' , $ _POST [ 'exclude' ] ) ; $ ids = array_merge ( $ ids , $ exclude ) ; } $ query -> set ( $ is_users ? 'exclude' : 'post__not_in' , $ ids ) ; } $ this -> maybe_callback ( $ query , $ _POST ) ; }
Modify the search query.

@since  1.2.4

@param  WP_Query  $query WP_Query instance during the pre_get_posts hook.

@return void
Modify the search query .