QKStudio

QKStudio

WordPress oEmbed Plus: Embed Facebook and Instagram posts easily

WordPress oEmbed Plus

WordPress has long supported the incorporation of external content such as Facebook videos, Instagram photos, YouTube videos, etc. simply using the URL of the same as source.


After placing on the WordPress post or page, the URL is “automagically” converted to an embedded Instagram post:

How does it work? WordPress uses oEmbed

Internally, the WordPress block editor uses the oEmbedprotocol and a legacy Facebook API to search for content from posts / photos / videos / etc. and embed the HTML in the post.

And what happened now? As of October 24, 2020, Facebook has disapproved of the legacy oEmbed API.

The legacy API that WordPress used to get embedded content did not require any credentials, such as an access token, to function, which made it possible to embed content from Facebook and Instagram without any additional configuration and very easily for any user.

Due to this change, as of WordPress 5.5.1, support for Facebook and Instagram content embeds has been removed and this functionality has been delivered to a third-party plugin.

How to embed Facebook and Instagram using a plugin?

The new WordPress auto-plug oEmbed Plus plugin brings back support for Facebook and Instagram oEmbed using the new Facebook API end points.

Once installed, this plugin needs to know an access token to the Facebook application to work. You can configure the API key and secret in Admin Panel → Settings → Write.

Register a Facebook app

With a Facebook acccount and logged into it, head to Facebook Developer Apps list to create a new app. Click “Add a New App“, and select “For Everything Else” for the use of it.

Now you need to register a Facebook application

With a Facebook account and signed in, go to the list of Facebook developer applications to create a new application. Click “Add a new app” and select “For everything else”to use it.

You will need to enter a name for the application and an email. The name of the application can be any name. The name and email will not be displayed at all in the WordPress interface.

Add oEmbed to the application

After the application is created, you must enable the oEmbed feature for the application.

From the “Products” list, add oEmbed by clicking “Configure“.

Embedded Facebook video

Enter additional application details

To complete and retrieve the API keys, the application must be active and complete.

The minimum requirement is to establish a privacy policy. You can use pretty much any URL as the technical aspect is considered, but use a proper privacy policy if you have one.

Switch the app to live mode

Using the switch at the top of the page that says “In development”, you can now switch the application to live mode.

You will be asked to enter additional details if something is missing.

Get App ID and Secret and go into plugin settings

To retrieve the App ID and Secret Key, go to Settings → Basic in the Facebook app. You will see the App ID and Secret, which you can enter in the WordPress oEmbed Plus settings.

Embedded Facebook video

Set the application ID and secret in the configuration file

As an alternative to setting the Facebook app ID and secret from the Administration settings page, it is also possible to set it in the wp-config.php

In a typical WordPress setup, the wp-config.phpfile contains various settings for the site. Edit this file and at the end of the file set the Facebook App ID and Secret by adding the following snippet:

define('OEMBED_PLUS_FACEBOOK_APP_ID', '<Enter App ID Here>');  
define('OEMBED_PLUS_FACEBOOK_SECRET', '<Enter Secret Here>');

Replace the <Enter App ID Here>and <Enter Secret Here>fields with the actual values. Make sure to remove the < >markers as well. For example, a configured value would look like this:

define('OEMBED_PLUS_FACEBOOK_APP_ID', '123...456');  
define('OEMBED_PLUS_FACEBOOK_SECRET', '123456abc...789def');

If configuration options are set in the wp-config.php, the admin panel form will be disabled and the wp-config.phpconfiguration will take precedence over the admin panel form configuration.

That’s it!

That’s it. Your existing embedded content will continue to work (as it is stored as rendered HTML content). New Facebook and Instagram content will use the new authenticated API.

Fare limits

Facebook allows up to 5 million requests a day. Once the content is embedded, the output is cached in the database and does not trigger any further requests.