wp_oembed_get

Attempts to fetch the embed HTML for a provided URL using oEmbed.

Description

(false|string) wp_oembed_get( (string) $url, (string) $args = '' ); 

Returns (false|string)

False on failure or the embed HTML on success.

Parameters (2)

0. $url (string)
The URL that should be embedded.
1. $args — Optional. (string) => ''
Additional arguments and parameters for retrieving embed HTML. Default empty.

Usage

  1. if ( !function_exists( 'wp_oembed_get' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // The URL that should be embedded. 
  5. $url = ''; 
  6.  
  7. // Optional. Additional arguments and parameters for retrieving embed HTML. 
  8. // Default empty. 
  9. $args = ''; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = wp_oembed_get($url, $args); 
  13.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/embed.php  
  1. function wp_oembed_get( $url, $args = '' ) { 
  2. $oembed = _wp_oembed_get_object(); 
  3. return $oembed->get_html( $url, $args );