Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Feed search problem › Reply To: Feed search problem
December 19, 2019 at 10:47 am
#25097
Keymaster
Hi,
I see what was wrong there, the developer didn’t mention, that the feed link URLs are not the default permalinks, but stored in a custom field. I have applied a custom code into the functions.php file in your theme, based on this knowledge base.
For future reference, this is the code applied:
add_filter( 'asp_results', 'asp_custom_link_meta_results', 10, 1 );
function asp_custom_link_meta_results( $results ) {
// Change this variable to whatever meta key you are using
$key = 'wprss_item_permalink';
// Parse through each result item
foreach ($results as $k=>$v) {
if ( function_exists('get_field') )
$new_url = get_field( $key, $v->id, true ); // ACF support
else
$new_url = get_post_meta( $v->id, $key, true );
// Change only, if the meta is specified
if ( !empty($new_url) ) {
$results[$k]->link = $new_url;
}
}
return $results;
}