Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Yoast title field › Reply To: Yoast title field
August 6, 2021 at 3:59 pm
#34211
Participant
This only replaced the title with the ID (you have $r->id in the filter)
But this pointed me to something useful – so thanks! Shared in case you ever need it for anyone else :
add_filter( 'asp_results', 'asp_force_yoast_title', 10, 1 );
function asp_force_yoast_title( $results ) {
foreach ($results as $k => &$r ) {
$r->title = apply_filters('the_title', $r->title);
$newtitle = 'My Site Name Replacement';
$realtitle = get_the_title($r->id);
$r->title = str_replace( array("%%sitename%%","%%sep%%","%%title%%","%%page%%"), array($newtitle, " | ", $realtitle,""), "$r->title" );
}
return $results;
}
-
This reply was modified 4 years, 10 months ago by
thewebco76.