apply_filters( 'relevanssi_do_not_read', boolean $block, int $post_id )
Controls whether an attachment’s content should be read or not.
Parameters
$block
(boolean) If true
, Relevanssi won’t read this attachment. Default false
.
$post_id
(int) The post ID of the attachment
post.
More information
When Relevanssi reads the attachment content, the first thing it does is checking the _relevanssi_hide_post
custom field to see if the post is blocked. That custom field value is then passed on to this filter hook. If the custom field or this filter hook returns true
, the attachment is not read.
If the attachment is not read, Relevanssi records that information in the _relevanssi_pdf_error
custom field.
Let’s assume we want to read all attachments, except those created by Bob, whose user ID is 23. This function would do that:
add_filter( 'relevanssi_do_not_read', 'rlv_no_attachments_from_bob', 10, 2 ); function rlv_no_attachments_from_bob( $block, $post_id ) { $_post = get_post( $post_id ); if ( 23 === $_post->post_author ) { $block = true; } return $block; }
If you wish to exclude attachments based on MIME type, you can use relevanssi_accept_mime_type
.