Title: WP_oEmbed::get_provider
Published: September 4, 2014
Last modified: February 24, 2026

---

# WP_oEmbed::get_provider( string $url, string|array $args ): string|false

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#wp--skip-link--target)

Takes a URL and returns the corresponding oEmbed provider’s URL, if there is one.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#see-also)󠁿

 * [WP_oEmbed::discover()](https://developer.wordpress.org/reference/classes/WP_oEmbed/discover/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#parameters)󠁿

 `$url`stringrequired

The URL to the content.

`$args`string|arrayoptional

Additional provider arguments. Default empty.

 * `discover` bool
 * Optional. Determines whether to attempt to discover link tags at the given URL
   for an oEmbed provider when the provider URL is not found in the built-in providers
   list. Default true.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#return)󠁿

 string|false The oEmbed provider URL on success, false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#source)󠁿

    ```php
    public function get_provider( $url, $args = '' ) {
    	$args = wp_parse_args( $args );

    	$provider = false;

    	if ( ! isset( $args['discover'] ) ) {
    		$args['discover'] = true;
    	}

    	foreach ( $this->providers as $matchmask => $data ) {
    		list( $providerurl, $regex ) = $data;

    		// Turn the asterisk-type provider URLs into regex.
    		if ( ! $regex ) {
    			$matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i';
    			$matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask );
    		}

    		if ( preg_match( $matchmask, $url ) ) {
    			$provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML.
    			break;
    		}
    	}

    	if ( ! $provider && $args['discover'] ) {
    		$provider = $this->discover( $url );
    	}

    	return $provider;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-oembed.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-oembed.php#L266)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-oembed.php#L266-L295)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_oEmbed::discover()](https://developer.wordpress.org/reference/classes/wp_oembed/discover/)`wp-includes/class-wp-oembed.php` |

Attempts to discover link tags at the given URL for an oEmbed provider.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  |

| Used by | Description | 
| [WP_oEmbed::get_data()](https://developer.wordpress.org/reference/classes/wp_oembed/get_data/)`wp-includes/class-wp-oembed.php` |

Takes a URL and attempts to return the oEmbed data.

  | 
| [wp_filter_oembed_result()](https://developer.wordpress.org/reference/functions/wp_filter_oembed_result/)`wp-includes/embed.php` |

Filters the given oEmbed HTML.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_oembed/get_provider/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.0.0](https://developer.wordpress.org/reference/since/4.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_oembed%2Fget_provider%2F)
before being able to contribute a note or feedback.