This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Show title tag instead of page name in search results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Show title tag instead of page name in search results Reply To: Show title tag instead of page name in search results

#6483
Ernest MarcinkoErnest Marcinko
Keymaster

Last time I gave up after 2 hours of trying, but I checked again and great news!

I’ve finally found the function responsible to replace the variables in post names. Please try this code:

[php]

add_filter( ‘asp_results’, ‘asp_get_seo_title’, 999999, 1 );

function asp_get_seo_title( $results ) {

foreach ($results as $k=>$v) {
// Continue if not pagepost
if ($results[$k]->content_type != "pagepost") continue;

// Get the seo title
$seo_title = get_post_meta($results[$k]->id, ‘_yoast_wpseo_title’, true);

// Modify it
if ($seo_title !== false && $seo_title != "")
$results[$k]->title = wpseo_replace_vars( $seo_title, get_post($results[$k]->id) );
}

return $results;
}
[/php]

It works on my test environment, and hopefully on yours as well 🙂