Useful Snippets


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at

RSS Latest posts from my personal blog

Most viewed posts

Subscribe to RSS feed

Facebook oEmbed support for WordPress

Stanislav KhromovStanislav Khromov

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

add_action('init', function() {

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

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

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
Twitter Profile
Visit my other blog

Comments 4