Javier Olona Klunder
asked 8 years ago

Hello, I would like the possibility to add Facebook videos in my video posts of DW Focus Theme.
I tried by the plugin WP Embed Facebook. I create an Api in Facebook and it works… when I insert a Facebook link video in a Page it is recognized as a video and I can watch it but when I insert the link in the first lines of the page (as I do with Youtube) video appears right to the share options and not in the place of the featured image (up to the share options).
This is a problem because I must upload a featured image and in the enlarged post I see the featured image in his place and the video down the featured image. And I would like the same behaviour like a Youtube video… I would like to see the video in the place of the featured image when you enlarge the post, as I can see with youtube videos.
Is that possible?
How could I do it?
(Excuse me for my bad English… if you need more explanation do not hesitate to contact me again).

3 Answers
answered 8 years ago

I know what you want. Currently, the DW Focus theme have customized and only embed video link from Vimeo, youtube and some other. It does not compatible with the third party plugin. In your case, you can send me username & password of your site via private answer, I will check and find a best solution to help you resolve it. 

Javier Olona Klunder
answered 8 years ago

Hello Dominic,
Thanks for your help.
The WordPress password is: (see next private post…)
If you go to “Publicaciones en blog” (Posts) >> “Todas las entradas” (All posts) I made a test in this post tittled: “This is a Facebook video embed test” (it is in draft, please do not publish it) you can preview in: http://www.ttdeporte.com/?p=2560&preview=true
As you will know, through a Facebook api and the plugin “WP Embed Facebook” I can see that video.
If you get any result, I think it could be an interesting update for next versions.
If you need ftp access let me know and I will provide you the keys.
Best regards,
P.D.: By the way, if you see the header you can see that I centered the tittle of the page and I created three new widget areas in header. Personally I prefer the original header but my customer want the logo of the page centered.

answered 8 years ago

Hi mate,seem like the account you provide doesn’t have the right to edit code, so, for your situation, to resolve this problem, please follow this guide:

  1. Open file :dw-focus/inc/init.php, change the code from line 103 -> 167 to this:
    function dw_focus_theme_oembed_videos() {
    global $post;
    if ( $post && $post->post_content ) {

    global $shortcode_tags;
    // Make a copy of global shortcode tags - we'll temporarily overwrite it.
    $theme_shortcode_tags = $shortcode_tags;

    // The shortcodes we're interested in.
    $shortcode_tags = array(
    'video' => $theme_shortcode_tags['video'],
    'embed' => $theme_shortcode_tags['embed']
    // Get the absurd shortcode regexp.
    $video_regex = '#' . get_shortcode_regex() . '#i';

    // Restore global shortcode tags.
    $shortcode_tags = $theme_shortcode_tags;

    $pattern_array = array( $video_regex );

    // Get the patterns from the embed object.
    if ( ! function_exists( '_wp_oembed_get_object' ) ) {
    include ABSPATH . WPINC . '/class-oembed.php';
    $oembed = _wp_oembed_get_object();
    $pattern_array = array_merge( $pattern_array, array_keys( $oembed->providers ) );

    // Or all the patterns together.

    $pattern = '#(' . array_reduce( $pattern_array, function ( $carry, $item ) {
    if ( strpos( $item, '#' ) === 0 ) {
    // Assuming '#...#i' regexps.
    $item = substr( $item, 1, -2 );
    } else {
    // Assuming glob patterns.
    $item = str_replace( '*', '(.+)', $item );
    return $carry ? $carry . ')|(' . $item : $item;
    } ) . ')#is';

    // Simplistic parse of content line by line.
    $lines = explode( "\n", $post->post_content );
    foreach ( $lines as $line ) {
    $line = trim( $line );
    if ( preg_match('/<iframe[^>]+src="([^"]+)"[^>]*>*<\/iframe>([Ss]*)/', $line, $reg_matches ) ) {
    $ret = $reg_matches[0];
    return $ret;
    } else {
    if ( preg_match('/<a[^>]+href="([^"]+)"[^>]*>(.+)<\/a>([Ss]*)/', $line, $reg_matches ) ) {
    $ret = wp_oembed_get( $reg_matches[1] );
    return $ret;
    } elseif ( preg_match( $pattern, $line, $matches ) ) {
    if ( strpos( $matches[0], '[' ) === 0 ) {
    $ret = do_shortcode( $matches[0] );
    } else {
    $ret = wp_oembed_get( $matches[0] );
    return $ret;
    } else {
    if ( class_exists( 'WP_Embed_FB' ) && preg_match( '/https:\/\/www.facebook.com\/.*\/videos.*\//' , $line, $reg_matches) ) {
    $juice = str_replace( array(
    ), '', $reg_matches[0] );
    $ret = WP_Embed_FB::fb_embed( array( 'https', '://www.facebook.com/', $juice ) );
    return $ret;

  2. open file style.css in your theme and add this code:
    .format-video .entry-content .fb-video { display:none; }

  3.  After that please go to dashboard >> setting >> embed facebook , and setting the width of the video , so it can be come larger that fit the post.

If you still have problem with it or you don’t know how to implement the code, you can provide me an account that have the right to edit theme/plugin code. I’ll help you on that.

Powered by DW Question & Answer Pro