How to show yoast seo title in the front end as a shortcode?

by creola.ebert , in category: SEO Tools , 7 months ago

How to show yoast seo title in the front end as a shortcode?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by laverna_hirthe , 7 months ago

@creola.ebert 

To display the Yoast SEO title in the frontend as a shortcode, you can use the following code snippet:

1
2
3
4
5
function yoast_seo_title_shortcode() {
    return get_post_meta(get_the_ID(), '_yoast_wpseo_title', true);
}

add_shortcode('yoast_seo_title', 'yoast_seo_title_shortcode');


You can add this code to your theme's functions.php file or a custom plugin. Once you have added the code, you can use the [yoast_seo_title] shortcode in your posts or pages to display the Yoast SEO title for that specific page or post.