wp_oembed_add_provider( string $format, string $provider, bool $regex = false )

Adds a URL format and oEmbed provider URL pair.


Top ↑

See also

Top ↑


$format string Required
The format of URL that this provider can handle. You can use asterisks as wildcards.
$provider string Required
The URL to the oEmbed provider.
$regex bool Optional
Whether the $format parameter is in a RegEx format.

Default: false

Top ↑


File: wp-includes/embed.php. View all references

function wp_oembed_add_provider( $format, $provider, $regex = false ) {
	if ( did_action( 'plugins_loaded' ) ) {
		$oembed                       = _wp_oembed_get_object();
		$oembed->providers[ $format ] = array( $provider, $regex );
	} else {
		WP_oEmbed::_add_provider_early( $format, $provider, $regex );

Top ↑


Version Description
2.9.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Codex

    Basic Example
    Register a provider for any URL beginning in http://site.com/watchvideo/ using a simple wildcard URL format:

    <?php wp_oembed_add_provider( 'http://site.com/watchvideo/*', 'http://site.com/oembedprovider' ); ?>

    Note: Do not leave empty space, neither before nor after

  2. Skip to note 2 content
    Contributed by Codex

    Register YouTube’s oEmbed provider for YouTube URLs using a regex URL format:

    <?php wp_oembed_add_provider( '#http://(www\.)?youtube\.com/watch.*#i', 'http://www.youtube.com/oembed', true ); ?>

    Note: YouTube is already registered by default with WordPress. This is merely an example, you do not need to register YouTube yourself.

You must log in before being able to contribute a note or feedback.