Update wpseo (Yoast) term title and description programmatically

Yoast metadata terms are stored in a row in the options table called “wpseo_taxonomy_meta”. The meta value of this option row contains a serialized string with all the SEO metadata for each term.

To update the metadata of a WordPress term you can use the WPSEO_Taxonomy_Meta::set_value( $term_id, $taxonomy, $meta_key, $meta_value ) function.

To for example update the meta title of a term use the following method:

WPSEO_Taxonomy_Meta::set_value( 123, 'taxonomy_name', 'title', 'This is my meta title' );

As you can see I use “title” for the meta title, but if you for example need to edit the wpseo_desc, use “desc” as meta_key.

I'm Robbert Vermeulen. I document everything I learn and help thousands of people with coding WordPress. My site has no ads or sponsors. If you enjoy my content, please consider supporting what I do.


    No comments yet..

Leave a reply

Feel free to ask questions or make comments.