The API shouldn’t have anything to do with oEmbed. The oEmbed process occurs when the post is served, not when or how it’s created. As far as the saved post goes, the embed is simply a bare URL in post content. When the post is served WP seeks out bare URLs and checks to see if any are related to an oEmbed server. If so, it attempts to fetch the related HTML which replaces the bare URL.
If your videos aren’t loading in an embed, the problem is more likely with the oEmbed server at the URL’s source. Or the oEmbed fetch process on your server has been corrupted by some theme or plugin conflict.
Hi @bcworkz –
Thank you for responding. The oEmbed process works within Gutenberg/Block Editor once viewing the edit screen, as it then saves the oEmbed post meta and the associated oEmbed post_type based on the oEmbed server response. However, if we create a post with video as a block via the REST API and then view that post in the front end without editing the post, the oEmbed process never occurs. We are processing over 1k posts with videos and cannot afford to edit each post manually to trigger the oEmbed process.
Here is an example of a post we are creating via the REST API:
REST API endpoint:
/wp-json/wp/v2/posts
Code
{
"content": "<!-- wp:embed {\"url\":\"https://www.youtube.com/embed/t1xaI36UXGY\",\"type\":\"rich\",\"providerNameSlug\":\"embed-handler\",\"responsive\":true,\"className\":\"is-provider-embed-handler wp-embed-aspect-16-9 wp-has-aspect-ratio\"} --><figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">https://www.youtube.com/embed/t1xaI36UXGY</div></figure><!-- /wp:embed --><!-- wp:paragraph --><p>This is a paragraph</p><!-- /wp:paragraph -->",
"slug": "api-video-test",
"status": "publish",
"title": "API Video Test",
"type": "post"
}
-
This reply was modified 4 years, 11 months ago by
WordHerd. Reason: clarification
-
This reply was modified 4 years, 11 months ago by
WordHerd.
Saving using wp-cli? That’s not my forte, sorry. If you tag this topic “wp-cli” it’ll help get the attention of wp-cli support volunteers.
@bcworkz Actually, it is via the WP REST API, not wp-cli. How would you recommend tagging in that case?
Except for wp-cli, tagging isn’t going to help garner more specific support, they’re more for others seeking help with similar problems.
The block editor saves via the API and its embeds don’t seem to have any trouble. Could there be something missing or aberrant in what you save? Compare your saved data with that from the block editor.