Mysql query to find all yoast meta description

In case you are are using Yoast plugin for SEO and using it to enter meta post description, you can query meta descriptions of all posts stored in custom field _yoast_wpseo_metadesc. This may be handy to bulk review the meta descriptions of all your posts and pages. Here are some queries to get custom field _yoast_wpseo_metadesc for all posts:

_yoast_wpseo_metadesc meta values for all posts

This query will display null in case _yoast_wpseo_metadesc meta_value does not exist.

SELECT p.ID, p.post_title, pm.meta_key, pm.meta_value
FROM wp_posts p
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id AND pm.meta_key = '_yoast_wpseo_metadesc'
WHERE p.post_type in ('post', 'page')
AND p.post_status='publish'

Posts with null _yoast_wpseo_metadesc meta value

This query will display all post where _yoast_wpseo_metadesc meta value does not exist.

SELECT p.ID, p.post_title, pm.meta_key, pm.meta_value
FROM wp_posts p
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id AND pm.meta_key = '_yoast_wpseo_metadesc'
WHERE p.post_type in ('post', 'page')
AND p.post_status='publish'
AND pm.meta_key IS NULL

Note these queries can be used to find meta value for other meta keys after slight modification.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments