Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Setting up pre-filters for an index › Reply To: Setting up pre-filters for an index
December 18, 2025 at 1:41 pm
#56601
Participant
Thanks Ernest for your help!
I have added the following code but its not getting the desired results.
add_filter('asp_index_post', function( $post ) {
if ( $post === null ) {
return $post;
}
// Only apply this filter to attachments (media)
if ( $post->post_type !== 'attachment' ) {
return $post;
}
$meta_key = 'available';
if ( function_exists('get_field') ) {
$available = get_field( $meta_key, $post->ID, false ); // ACF support
} else {
$available = get_post_meta( $post->ID, $meta_key, true );
}
// Check if the field exists and is truthy (1, "1", true, "yes", etc.)
if ( !empty($available) && $available !== '0' && $available !== 0 ) {
return $post;
}
return null;
}, 10, 1);
When I run the logic to just list results, I get 717 items, which seems right. But when I delete and re-index, its only return 74 items.
Anything we can try here? I’ve add some login info to the ticket if that helps.
Let me know, thanks.
Seamus