filter

jetpack_search_es_wp_query_args

Modify the search query parameters, such as controlling the post_type. These arguments are in the format of WP_Query arguments

Parameters

$es_wp_query_args
array

The current query args, in WP_Query format.

$query
WP_Query

The original WP_Query object.

Changelog

How to use this hook

See “How to use actions and filters to customize Jetpack”.

Notes

You can use this filter to customize the post types that will be included in search results when using Jetpack Search. In the example below, we only keep posts and pages in search results, instead of allowing all publicly queryable post types:
/**
 * Only keep posts and pages in search results.
 *
 * @see https://developer.jetpack.com/hooks/jetpack_search_es_wp_query_args/
 *
 * @param array    $query_args The current query args, in WP_Query format.
 * @param WP_Query $query      The original query object.
 */
function jeherve_limit_post_types_search( $query_args, $query ) {
	$query_args['post_type'] = array( 'post', 'page' );

	return $query_args;
}
add_filter( 'jetpack_search_es_wp_query_args', 'jeherve_limit_post_types_search', 10, 2 );