Title: wp_embed_register_handler
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_embed_register_handler( string $id, string $regex, callable $callback, int $priority = 10 )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#user-contributed-notes)

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

Registers an embed handler.

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

Should probably only be used for sites that do not support oEmbed.

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

 `$id`stringrequired

An internal ID/name for the handler. Needs to be unique.

`$regex`stringrequired

The regex that will be used to see if this handler should be used for a URL.

`$callback`callablerequired

The callback function that will be called if the regex is matched.

`$priority`intoptional

Used to specify the order in which the registered handlers will be tested.

Default:`10`

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

    ```php
    function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
    	global $wp_embed;
    	$wp_embed->register_handler( $id, $regex, $callback, $priority );
    }
    ```

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

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

| Uses | Description | 
| [WP_Embed::register_handler()](https://developer.wordpress.org/reference/classes/wp_embed/register_handler/)`wp-includes/class-wp-embed.php` |

Registers an embed handler.

  |

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

Determines if default embed handlers should be loaded.

  |

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#comment-content-1209)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/#comment-1209)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%23comment-1209)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%23comment-1209)
 4.  **Basic Example**
 5.  Register an embed handler for Forbes video embeds.
 6.      ```php
         wp_embed_register_handler(
         	'forbes',
         	'#http://(?:www|video)\.forbes\.com/(?:video/embed/embed\.html|embedvideo/)\?show=([\d]+)&format=frame&height=([\d]+)&width=([\d]+)&video=(.+?)($|&)#i',
         	'wpdocs_embed_handler_forbes'
         );
     
         function wpdocs_embed_handler_forbes( $matches, $attr, $url, $rawattr ) {
     
         	$embed = sprintf(
         			'<iframe src="http://www.forbes.com/video/embed/embed.html?show=%1$s&format=frame&height=%2$s&width=%3$s&video=%4$s&mode=render&quot; width="%3$spx" height="%2$spx" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>',
         			esc_attr($matches[1]),
         			esc_attr($matches[2]),
         			esc_attr($matches[3]),
         			esc_attr($matches[4])
         			);
     
         	return $embed;
         }
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%3Freplytocom%3D1209%23feedback-editor-1209)
 8.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#comment-content-6232)
 9.    [cogdog](https://profiles.wordpress.org/cogdog/)  [  3 years ago  ](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/#comment-6232)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%23comment-6232)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%23comment-6232)
 11. Here is a means to add oembed support for web-based audio recorders Vocaroo and
     Sodaphonic. I found the hard way that sprintf fails when you have a “%” in the
     string
 12.     ```php
         add_action( 'init', 'cdb_register_embeds' );
         function dcb_register_embeds() {
         	// handler for vocaroo audio
         	wp_embed_register_handler(
         		'vocaroo',
         		'#^https?://(vocaroo.com|voca.ro)/([a-zAA-Z0-9]+)$#i',
         		'cdb_handler_vocaroo'
         	);
     
         	// handler for sodaphonic boombox audio	
         	wp_embed_register_handler(
         		'sodaphonic',
         		'#^https?://sodaphonic.com/audio/([a-zAA-Z0-9]+)(.*)$#i',
         		'cdb_handler_sodaphonic'
         	);
         }
     
         function cdb_handler_vocaroo( $matches, $attr, $url, $rawattr ) {
         $embed = '';
         return $embed;
         }
     
         function cdb_handler_sodaphonic( $matches, $attr, $url, $rawattr ) {
         $embed = '';
     
         return $embed;
         }
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%3Freplytocom%3D6232%23feedback-editor-6232)
 14.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/?output_format=md#comment-content-2826)
 15.   [Ryan McCue](https://profiles.wordpress.org/rmccue/)  [  8 years ago  ](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/#comment-2826)
 16. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%23comment-2826)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%23comment-2826)
 17. Note that the `$regex` parameter is checked against the URL, not against the content,
     so you can anchor the regular expression with `^` and `$`. This is useful if you
     want to use an ungreedy match group at the end of your URL:
 18.     ```php
         wp_embed_register_handler( $id, '#^http://example.com/(\?.+)?$#', __NAMESPACE__ . '\\handle_embed' );
         ```
     
 19.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_embed_register_handler%2F%3Freplytocom%3D2826%23feedback-editor-2826)

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