apply_filters( 'relevanssi_index_get_post_type', string $type, object $post )

Adjusts the value of the type column for the post.


(string) The type of the post, default post.

(object) The post object; usually a WP_Post object, but not always.

More information

Relevanssi has a type column in the wp_relevanssi database table, specifying the type of the content the indexed term is coming from. For all posts, it’s post, except for the attachments, which get attachment. You can also have user for user profiles and the name of the taxonomy for the taxonomy terms.

This filter hook can be used to adjust this value.

The default behaviour here is this:

add_filter( 'relevanssi_index_get_post_type', 'relevanssi_index_get_post_type', 1, 2 );

function relevanssi_index_get_post_type( $type, $post ) {
	if ( 'attachment' === $post->post_type ) {
		$type = 'attachment';
	return $type;