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
January 19, 2026 at 8:38 pm
#56793
Keymaster
I have very good news, I managed to find a solution, which hooks into the query to check the field existence and value. Use this snippet only:
add_filter(
'asp/index/database/get_posts_to_index/query/add_where',
function ( $add_where ) {
global $wpdb;
return $add_where . " AND (
( post.post_type='attachment' AND EXISTS(SELECT 1 FROM $wpdb->postmeta WHERE post_id=post.ID AND meta_key='available' AND meta_value=1) )
OR post.post_type <> 'attachment'
)";
}
);
This will exclude everything during the query, so the exclusion field is not populated with so many items, they don’t even get queued at all.
-
This reply was modified 4 months, 2 weeks ago by
Ernest Marcinko.