Yoast Metadata API to adjust/override the meta description
I wanted to use the following function to override the Yoast meta description:
add_filter('wpseo_metadesc','custom_meta');
function custom_meta( $desc ){
if (/* do your test here to check template or any other values*/) {
$desc = Change the description;
}
return $desc;
}
However, Yoast SEO support recommends the Metadata API.
From this page, I understand I can use the wpseo_metadesc
filter to adjust the Meta_Description_Presenter
, but I am unsure how it is done; I am not a programmer.
I'd love some assistance to create some functions.php
code that will grab the first 160 characters of the content if the meta description hasn't been set already.
Help appreciated. Steve
Topic plugin-wp-seo-yoast Wordpress
Category Web