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

#6228

Ernest Marcinko
Keymaster

Hm, maybe it needs to be filtered with the “the_title” filter.

Try changing that code to:

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  = apply_filters( 'the_title', $seo_title );
  }
  
  return $results;
}
Best,
Ernest Marcinko

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