embed_oembed_html

Home » Hooks » embed_oembed_html

The embed_oembed_html hook is a filter hook in WordPress that allows you to modify the oEmbed HTML code generated for a post’s embed block. When you use the oEmbed service to embed content from another website into your WordPress site, this hook can be used to modify the HTML code that gets generated.

This hook gives you the ability to add or remove HTML elements or attributes, change the styling of the embed block, or make any other modifications to the oEmbed HTML that you might need to customize the display of the embedded content.

An example usage code for this hook might look like this:

function my_custom_embed_html( $html, $url, $attr ) {
    // Modify the HTML code as needed
    return $html;
}
add_filter( 'embed_oembed_html', 'my_custom_embed_html', 10, 3 );

In this example, we define a custom function called my_custom_embed_html that accepts the $html, $url, and $attr parameters. We can modify the $html variable to change the oEmbed HTML code, and then return the modified $html.

The add_filter function is used to hook our custom function into the embed_oembed_html filter, with a priority of 10 and three arguments. This allows our custom function to receive the $html, $url, and $attr arguments passed by the filter.

Learn More on WordPress.org

WordPress snippets using the embed_oembed_html hook

Register an account to save your snippets or go Pro to get more features.