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 15, 2025 at 2:47 pm
#56522
Keymaster
Hi Seamus,
Thank you for the details, it helps me understand the issue better.
You are looking for this hook:
apply_filters('asp_index_post', WP_Post $post, array $args);
In your case, the final code will look something like this:
add_filter('asp_index_post', function( $post ) {
if ( $post === null ) {
return $post;
}
$meta_key = 'available';
if ( function_exists('get_field') ) {
$available = get_field( $meta_key, $post->ID, true ); // ACF support
} else {
$available = get_post_meta( $post->ID, $meta_key, true );
}
if ( $available ) {
return $post;
}
return null;
}, 10, 1);
Basically whenever the hooked function returns null, the post is skipped from the index. In the code above a check is made on the “available” custom field. If it is true, then the post is returned, otherwise null. It may need some testing to make sure the field values are that, but based on your description I assumed this solution.