Getting a 404 Error with Vimeo on WordPress? Get the Solution Here

Getting a 404 Error with Vimeo on WordPress? Get the Solution Here

WordPress users who embed Vimeo videos with oEmbed came across a frustrating problem last week when their videos stopped working. It turns out that it’s a simple problem, with  a simple solution, but no doubt it has been causing Vimeo users hours of frustration.

The Problem

WordPress Core registers Vimeo as this:

'#http://(www\.)?vimeo\.com/.*#i' => array( 'http://www.vimeo.com/api/oembed.{format}', true ),

However, the Vimeo API for oEmbed has the URL without the www. So this works:

http://vimeo.com/api/oembed.json?maxwidth=584&maxheight=600&url=http%3A%2F%2Fvimeo.com%2F30230507&format=json

but the former doesn’t.

The Solution

There are two solutions to this problem with Vimeo which should get you back on track.

Code

You can add this piece of code to your functions file which will register Vimeo correctly:

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

add_action('init', 'add_vimeo_oembed_correctly');
function add_vimeo_oembed_correctly() {
wp_oembed_add_provider( '#http://(www\.)?vimeo\.com/.*#i', 'http://vimeo.com/api/oembed.{format}', true );
}

Thanks to Brady for this solution.

Plugin

Another WordPress user has created a plugin which solves the problem. You can download the plugin from here.

WordPress are aware of this issue and a trac ticket was raised. The problem has been fixed so next time you update the problem should be solved.

Tags: