Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posts published through the REST API have incomplete opengraph headers #17746

Closed
2 tasks done
wodim opened this issue Dec 1, 2021 · 4 comments
Closed
2 tasks done

Posts published through the REST API have incomplete opengraph headers #17746

wodim opened this issue Dec 1, 2021 · 4 comments

Comments

@wodim
Copy link

wodim commented Dec 1, 2021

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Whenever I submit a post to my site using the REST API, the code Yoast SEO adds to the header of the resulting post is incomplete.

image

The canonical URL is wrong (it says "sin-categoria", in other words, "uncategorised") and the featured image is not shown.

Please describe what you expected to happen and why.

After using the "reset indexables" button of the Yoast Test Helper plugin the correct information is shown (category name corrected and featured image included):

image

Technical info

Used versions

  • WordPress version: 5.8.2
  • Yoast SEO version: 17.7.1
@Djennez
Copy link
Member

Djennez commented Dec 2, 2021

@wodim can you share the reproduction steps for your issue? Like the command(s) used to create a post.

@wodim
Copy link
Author

wodim commented Dec 2, 2021

This would be python code but you can translate it into a php curl or regular curl call.

         requests.post('https://example.com/wp-json/wp/v2/posts',
                       headers={'Authorization': b'Basic ' + b64encode(b'admin:mypass')},
                       data={'title': post_title, 'status': 'publish', 'content': post_content,
                             'categories': [post_category_id], 'featured_media': image_id,})

Where image_id is the id of some image that already exists in the blog.

@Djennez
Copy link
Member

Djennez commented Dec 3, 2021

Can confirm, this is actually the same issue as #17721, because the API triggers update_post_meta() which we don't watch. Because that issue is open, and we have an internal issue here and they all have the same root cause, I am closing this as duplicate.

@Djennez Djennez closed this as completed Dec 3, 2021
@wodim
Copy link
Author

wodim commented Dec 18, 2021

Found an easy workaround: immediately after posting, edit the post from the API, even if you don't actually change anything at all. For example, since my posts aren't sticky, I do this:

requests.post('https://example.com/wp-json/wp/v2/posts/%d' % post_id, data={'sticky': False,})

This doesn't change anything in the post, but the OG headers are regenerated properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants