Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › PDF search results › Reply To: PDF search results
January 5, 2023 at 1:03 pm
#40768
Keymaster
Hi,
1.Okay, I have logged in to check and made a tiny modification. Can you please test if this changed anything.
For reference the new code is:
add_filter( 'asp_results', 'asp_attachment_parent_in_category', 10, 1 );
function asp_attachment_parent_in_category( $results ) {
// Category IDs
$categories = array(28);
foreach ($results as $k=>&$r) {
if ( isset($r->post_type) && $r->post_type == 'attachment' ) {
$parent_id = wp_get_post_parent_id( $r->id );
if ( !is_wp_error($parent_id) && !empty($parent_id) ) {
if ( $parent_id == 0 || !in_category($categories, $parent_id) ) {
unset($results[$k]);
}
} else {
unset($results[$k]);
}
}
}
return $results;
}