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 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:


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;
}

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

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)