Skip to content


How-to Guides

Technical References

Enterprise Search /

Identify which post types are indexed

Identify in your codebase all of the custom queries, or query filters, where the post_type field is set, and which values it has.

Public post types are indexed by default

Enterprise Search will automatically index all public post types. But you may have certain non-public post types that need to be indexed (this is rare) or you want to exclude from indexing certain public post types (this is more typical). To do this, you can modify an allow list for post types by using the ep_indexable_post_types ElasticPress filter.

For example, in this pre_get_posts code that is customizing search when in the events section of the site, the post_type to index is event:

add_action( 'pre_get_posts', 'my_event_query_filter' );

function my_event_query_filter( $query ) {
    if ( $query->is_main_query() && get_query_var( 'events', false ) ) {
        $query->set( 'post_type' ), 'event' );

So event should already be in the post_type allow list. There’s nothing needed for events, except verifying that these post types can be searched. (But read on: the post meta are not indexed by default).

You may find similar post type declarations within various query filters, or within WP_Query arguments.

Excluding post types from the allow list

If you’re using the Comprehensive Sitemaps plugin, however, which uses a custom post type msm_sitemap, you will probably want to exclude those from indexing; the posts don’t contain information that you’d be displaying to users. The allow list can be used to block indexing, by removing the entry.

To declare that the msm_sitemap custom post type (and a few others) should not be indexed:

function mysite_events_indexable_post_types( $types ) {
	$deny_list = array( 'ai_log', 'msm_sitemap', 'wlo_option', 'vip-legacy-redirect' );
	// unset the items with values matching the deny list
	$types = array_diff( $types, $deny_list );
	return $types;
add_filter( 'ep_indexable_post_types', 'mysite_events_indexable_post_types', 10, 1 );

Note the filter above uses a list that looks as follows:

	'event' => 'event',
	'post'  => 'post',
	'page'  => 'page',

Because this is a filter, you can declare this filter in your events code independently of any site-wide filter, as long as the end result is a list of post types that should be indexed.

Last updated: November 16, 2021