WordPress Gutenberg doesn’t parse Istagram oembed url

Sometimes Instagram embed doesn’t work, why?

Novembre 4, 2019

This problem probably isn’t related to the new Gutenberg text editor, which is fantastic (the name comes from the inventor of the printing technique), but probably is related to another cause:

Broken Instagram oembed {{unknown}} in database

If you doesn’t see the embed but you see only the URL of the Instagram embed, it means that WordPress doesn’t modify your code to add the Instagram embed. You can see if in your database in the table wp_postmeta you have some broken oembed code for your post (use the post_id to find the value). If this is your problem you will see meta_value for that field which contains the string {{unknown}}. Remove the record to fix the problem.

You’ve changed the_content in get_the_content

If you write your theme maybe you would like to perform some string changes in your contents, and to make the changes you’ve just modified the_content() in $content=get_the_content(); and made your changes to $content. This change blocks your oembed content rendering, which is made during the application of some filters that happens inside the_content() function.

So to fix the problem and keep doing your stuff in $content string you should make:

$content = get_the_content();
// perform something on $content string
$content = apply_filters("the_content",$content);

Pay attention that the apply_filters modifies the html. So if you performs some changes between the two lines you could prevent apply_filters to work, for example if you modify the Instagram url.

On the other side, if you perform something on $content string after the apply_filters remember that after that line the HTML is changed and it will contain the Instagram embed code.

A plugin made some bad things

If your oembed problem doesn’t belong to the first two points, you probably have a conflict with a plugin which performs something on your content. Have you checked your plugins?

Author

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.