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

#6207
Ernest MarcinkoErnest Marcinko
Keymaster

I have come up with something that might just work.

If the SEO title is set on the Post editor, then it’s probably possible to get it as post meta. Try putting this code to your themes functions.php file (to the bottom):

[php]add_filter( ‘asp_results’, ‘asp_get_seo_title’, 1, 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 = $seo_title;
}

return $results;
}[/php]

I havent tested this code, but I’m hoping it will work.