0

I want to add a featured image, and since I am using Yoast SEO, I also want to add a focus keyphrase, SEO title, and meta description using the Python REST API, but I don't know how to proceed further.

import requests
import json
import base64

url = "https://exampleurl.com/wp-json/wp/v2/posts" 
user = "Username" 
password = "application password" 
credentials = user + ':' + password 
token = base64.b64encode(credentials.encode()) 
header = {'Authorization': 'Basic ' + token.decode('utf-8')} 
post = {  'title'    : 'Test WP-API',   
          'content'  : 'This is my first post created using restAPI',  
          'status'   : 'draft', 
} 
responce = requests.post(url , headers=header, json=post)

print(responce.json())
1
  • Yoast will most likely be storing this info as post meta data, so you need to figure out the correct meta field names, and then provide them via the meta parameter. Commented Dec 17, 2024 at 8:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.