Title: WP_Embed::register_handler
Published: April 25, 2014
Last modified: April 28, 2025

---

# WP_Embed::register_handler( string $id, string $regex, callable $callback, int $priority = 10 )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_embed/register_handler/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_embed/register_handler/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_embed/register_handler/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_embed/register_handler/?output_format=md#related)

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

Registers an embed handler.

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

Do not use this function directly, use [wp_embed_register_handler()](https://developer.wordpress.org/reference/functions/wp_embed_register_handler/)
instead.

This function should probably also only be used for sites that do not support oEmbed.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/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.
 Lower
numbers correspond with earlier testing, and handlers with the same priority are
tested in the order in which they were added to the action.

Default:`10`

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

    ```php
    public function register_handler( $id, $regex, $callback, $priority = 10 ) {
    	$this->handlers[ $priority ][ $id ] = array(
    		'regex'    => $regex,
    		'callback' => $callback,
    	);
    }
    ```

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

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

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

Registers an embed handler.

  |

## User Contributed Notes

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