Facebook oEmbed support for WordPress

Facebook has now publicly released oEmbed support, and a WordPress core ticket is under way to add support in a future WordPress version.

If you want to try out the new Facebook oEmbed support today, you can download and install this plugin: GitHub project or Direct zip download.

Here is an example of what the embed looks like:

If you prefer the code, here it is in its entirety:

Plugin Name: Facebook oEmbed
Version: 1.1
Author: khromov

 * https://core.trac.wordpress.org/ticket/34737
add_action('init', function() {

    $endpoints = array(
        '#https?://www\.facebook\.com/video.php.*#i'          => 'https://www.facebook.com/plugins/video/oembed.json/',
        '#https?://www\.facebook\.com/.*/videos/.*#i'         => 'https://www.facebook.com/plugins/video/oembed.json/',
        '#https?://www\.facebook\.com/.*/posts/.*#i'          => 'https://www.facebook.com/plugins/post/oembed.json/',
        '#https?://www\.facebook\.com/.*/activity/.*#i'       => 'https://www.facebook.com/plugins/post/oembed.json/',
        '#https?://www\.facebook\.com/photo(s/|.php).*#i'     => 'https://www.facebook.com/plugins/post/oembed.json/',
        '#https?://www\.facebook\.com/permalink.php.*#i'      => 'https://www.facebook.com/plugins/post/oembed.json/',
        '#https?://www\.facebook\.com/media/.*#i'             => 'https://www.facebook.com/plugins/post/oembed.json/',
        '#https?://www\.facebook\.com/questions/.*#i'         => 'https://www.facebook.com/plugins/post/oembed.json/',
        '#https?://www\.facebook\.com/notes/.*#i'             => 'https://www.facebook.com/plugins/post/oembed.json/'

    foreach($endpoints as $pattern => $endpoint) {
        wp_oembed_add_provider( $pattern, $endpoint, true );

4 thoughts on “Facebook oEmbed support for WordPress

  1. Pingback: [ASK] wordpress - Getting results from wp_oembed_add_provider | Some Piece of Information

  2. Ralf

    hi stanislav, this is great. How must the code be modified so that oEmbed for Facebook would also work within a buddypress stream?

    Thank you for your help!


Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.