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.

Robbert Vermeulen

Need help from a WordPress expert?

I would love to hear about your project and how I can help you achieve your goals