Get focus keyword through WordPress API for a post
-
Hey there,
I’m trying to retrieve focus keyword from a draft post using wordpress API.
I manage to get the description, title and content but I don’t knwo why i cannot get the yoast focus Keyword.
Do you have any idea of what I can do ?
here is a sample of the script I’m using :
from wordpress_xmlrpc import Client, WordPressPost from wordpress_xmlrpc.methods.posts import GetPost # website connexion url = '' username = '' password = '' # client client = Client(url, username, password) # Article ID post_id = 12345 # data post = client.call(GetPost(post_id)) print(post) # meta yoast_title = None yoast_description = None yoast_keywords = None for meta_field in post.custom_fields: if meta_field.keys == '_yoast_wpseo_title': yoast_title = meta_field.value elif meta_field.keys == '_yoast_wpseo_metadesc': yoast_description = meta_field.value elif meta_field.keys == '_yoast_wpseo_focuskw': yoast_keywords = meta_field.value # display print("Titre Yoast:", yoast_title) print("Description Yoast:", yoast_description) print("Mots-clés Yoast:", yoast_keywords)
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Get focus keyword through WordPress API for a post’ is closed to new replies.