Use Yoast SEO meta title in site search

For more information, see Yoast SEO title and description in site search results.

$title = ''; if( is_search() && function_exists( 'wpseo_replace_vars' ) ) { global $post; $title = get_post_meta( get_the_ID(), '_yoast_wpseo_title', true ); $title = wpseo_replace_vars( $title, $post ); } if( empty( $title ) ) { $title = get_the_title(); }

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk