Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Omit URL from Search › Reply To: Omit URL from Search
September 23, 2019 at 9:19 am
#24101
Keymaster
Hi,
The file name exclusion is actually a good feature idea. I might add it to the upcoming release.
I have made a custom code, which might actually do the exclusion in a post process. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter('asp_results', 'asp_results_change_image_by_name', 10, 1);
function asp_results_change_image_by_name($results) {
$exclude = 'icon16x16.png';
foreach ( $results as $k => &$r ) {
if ( $r->content_type != 'pagepost' )
continue;
if ( !empty($r->image) && strpos($r->image, $exclude) !== false ) {
$r->image = wpdreams_get_image_from_content(get_post_field('post_content', $r->id), 1);
}
}
return $results;
}
Please be careful, as I have not been able to test this code.