FacetWP – index attachment file type

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

function fwp_index_attachment_type( $params, $class ) {
if ( ‘file_type’ == $params[‘facet_name’] ) {
$post_id = (int) $params[‘post_id’];
$mime_type = get_post_mime_type( $post_id );
$filetype = explode( ‘/’, $mime_type );
$filetype = strtoupper( $filetype[1] );

$params[‘facet_value’] = $filetype; // changed $parms to $params
$params[‘facet_display_value’] = $filetype;
}
return $params;
}

add_filter( ‘facetwp_index_row’, ‘fwp_index_attachment_type’, 10, 2 );
{{/gist}}