Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › PDF search results › Reply To: PDF search results
Hi,
1. In theory, something like this could do the trick:
add_filter( 'asp_results', 'asp_attachment_parent_in_category', 10, 1 );
function asp_attachment_parent_in_category( $results ) {
// Category IDs
$categories = array(1, 2, 3);
foreach ($results as $k=>&$r) {
if ( $r->content_type == 'attachment' ) {
$parent_id = wp_get_post_parent_id( $r->id );
if ( !is_wp_error($parent_id) && !empty($parent_id) ) {
if ( !in_category($categories, $parent_id) ) {
unset($results[$k]);
}
}
}
}
return $results;
}
This only works with categories – no other taxonomy terms or anything else. The $categories variable holds the category IDs for which you want the parents to be restricted, don’t forget to change that.
2. This may not be possible without actual changes on the theme. The plugin forces the same titles/contents/links for the results page, but usually the results page queries these fields individually and therefore it refreshes them from the database.
There is still hope though, try this custom code:
add_filter( 'asp_regular_search_result', 'asp_force_guids', 10, 1 );
function asp_force_guids( $r ) {
if ( isset($r->asp_data) ) {
$r->guid = $r->asp_data->link;
$r->post_excerpt = $r->asp_data->content;
$r->post_content = $r->asp_data->content;
}
return $r;
}
3. Not yet, there are potential security vulerability concerns that has to be resolved to make it safe for release. It will be implemented for sure though.