The oembed_discovery_links WordPress PHP filter modifies the HTML of the oEmbed discovery links.
Usage
add_filter('oembed_discovery_links', 'your_custom_function'); function your_custom_function($output) { // Your custom code here return $output; }
Parameters
$output
(string) – HTML of the discovery links
More information
See WordPress Developer Resources: oembed_discovery_links
Examples
Remove oEmbed discovery links
Remove all oEmbed discovery links from the site.
add_filter('oembed_discovery_links', 'remove_oembed_links'); function remove_oembed_links($output) { return ''; }
Add a custom attribute to oEmbed discovery links
Add a “data-custom-attribute” attribute to the oEmbed discovery links.
add_filter('oembed_discovery_links', 'add_custom_attribute_to_links'); function add_custom_attribute_to_links($output) { return str_replace('<link', '<link data-custom-attribute="example-value"', $output); }
Modify oEmbed discovery link URLs
Add a query parameter to oEmbed discovery link URLs.
add_filter('oembed_discovery_links', 'modify_oembed_link_urls'); function modify_oembed_link_urls($output) { $output = preg_replace_callback('/href="([^"]+)"/', function($matches) { return 'href="' . $matches[1] . '?custom_param=value"'; }, $output); return $output; }
Add a custom oEmbed discovery link
Add an additional oEmbed discovery link with a custom URL.
add_filter('oembed_discovery_links', 'add_custom_oembed_link'); function add_custom_oembed_link($output) { $custom_link = '<link rel="alternate" type="application/json+oembed" href="https://example.com/custom_oembed.json" />'; return $output . $custom_link; }
Wrap oEmbed discovery links in a div
Wrap all oEmbed discovery links in a div with a custom class.
add_filter('oembed_discovery_links', 'wrap_oembed_links_in_div'); function wrap_oembed_links_in_div($output) { return '<div class="custom-oembed-links">' . $output . '</div>'; }