apply_filters ( 'jetpack_search_es_wp_query_args', array $es_wp_query_args, WP_Query $query )

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

Source file: modules/search/class.jetpack-search.php

View in GitHub

Parameters

$es_wp_query_args

(array) The current query args, in WP_Query format.

$query

(WP_Query) The original WP_Query object.


Changelog

Since: Jetpack 5.0.0


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 );

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s