How to filter WP attachments

By default, FacetWP only indexes published items, which excludes attachments.

Indexing attachments

To index attachments (media items), add this hook into your (child) theme’s functions.php file, then press the re-index button afterwards:

add_filter( 'facetwp_indexer_query_args', function( $args ) {
    $args['post_status'] = [ 'publish', 'inherit' ];
    return $args;
});

Displaying attachments

Attachments are post types that have post_status = inherit, meaning that they’re not technically published and won’t display by default. To show them, you’ll need to manually set the post status. If using the Layout Builder, you can do this within the Query┬átab: