I’m trying to insert meta description for my WordPress post, but the meta-description is always empty.
This is my code:
post_data = {
'title': title,
'content': markdown.markdown(content),
'slug': slug,
'status': 'publish',
'yoast_meta' : {
'yoast_wpseo_metadesc' : meta_description
},
'author': author_id,
'categories': [category_id], # Assign the category ID to the post
'meta': {
'meta_description': meta_description,
},
}
I’m not sure if the field name is the right one or if Yoast even supports feeding the meta description from API.
2
Answers
You need to use the
_yoast_wpseo_metadesc
key instead ofyoast_wpseo_metadesc
, as this is the actual key used by Yoast SEO to store the meta description.Had the same issue. If you install the following plugin: https://github.com/ChazUK/wp-api-yoast-meta
You can do the following: