How can I Get Yoast Meta from Post instead of Wordpress Meta?

- 1 answer

Ad

i'm building a Wordpress Theme and we will work with Yoast do build all the SEO.

So, I would like to know how can I get at index.php/category.php and in other pages the Yoast Meta from the post instead of the normal Wordpress Meta?

<?php echo substr(strip_tags($post->post_content), 0, 100);?>

this is how I get the 100 first characters from the post, So, I need to get the first 100 from Yoast SEO Meta Description!

Thx

Ad

Answer

Ad

What exactly is the problem? This will do the trick just fine.

echo substr(get_post_meta($post->ID, '_yoast_wpseo_metadesc', true), 0, 100);
Ad
source: stackoverflow.com
Ad