Migrating a Yoast meta description to a WordPress post excerpt

Last Updated: April 24, 2019

I have yet to meet a WordPress “SEO” plugin that I love, but Yoast checks most of the boxes.

One of Yoast’s features allows the user to supply a meta description for each individual page or post, e.g.:

However, to avoid creating lock-in, my strong preference is to use the default WordPress excerpt for the meta description instead, e.g.:

The excerpt — a brief, 1-2 sentence summary — is ideally suited for this task, and should our client ever discontinue use of Yoast, they don’t have to worry about losing their meta descriptions or replicating them over.

Then, we can tell Yoast to use our Excerpt for the meta description:

But what if you’ve already been using the Yoast meta description field across dozens or even hundreds of historical posts? Fortunately, a quick SQL query can make the migration painless.

UPDATE wp_posts
INNER JOIN wp_postmeta ON( wp_posts.ID = wp_postmeta.post_id )
SET wp_posts.post_excerpt = wp_postmeta.meta_value
WHERE wp_postmeta.meta_key = '_yoast_wpseo_metadesc';

Once copied successfully, then to avoid confusion over which field is to be used going forward, you can then remove the past Yoast meta descriptions altogether:

UPDATE wp_postmeta
SET wp_postmeta.meta_value = ''
WHERE wp_postmeta.meta_key = '_yoast_wpseo_metadesc';
Posted in ,

Chris Aram

I'm a developer who specializes in whipping your technology into shape so that it makes your professional and personal life better.