oEmbed Provider Generator
Paste a URL, get an embed. For services with a real oEmbed endpoint that is one line; for the ones without, this writes the regex handler instead.
Which kind
wp_oembed_add_provider() — one call. WordPress fetches the endpoint, caches the response and prints whatever html the service returns. Check the service docs for /oembed or a .well-known entry before assuming it has none.
Provider details
endpoint + pattern
A glob with * wildcards, or a regex if you turn that on below.
WordPress appends ?url= and &format=json itself. Do not include either.
Embed frame
Pattern is a regex
Passes true as the third argument, so your pattern is used verbatim.
Cache-flush helper
A function that clears _oembed_ post meta after you change the markup.
oembed_ttl filter
How long a failed lookup is remembered before WordPress retries.
Trust the host for redirects
Adds it to allowed_redirect_hosts. Unrelated to embedding — only if you need it.
Test URL
MatchesCaptured: abc123
A single-file plugin, so pasted URLs keep working after a redesign.
<?php // Generated with WP CodeKit — powered by GrowQuest (https://growquest.io). /** * Plugin Name: Acme Video embeds * Description: Auto-embeds Acme Video URLs pasted into the editor. * Version: 1.0.0 * Requires PHP: 7.4 */ defined( 'ABSPATH' ) || exit; /** * Register the Acme Video oEmbed provider. * * WordPress appends ?url= and &format=json itself. */ function acme_register_provider() { wp_oembed_add_provider( 'https://video.example.com/watch/*', 'https://video.example.com/oembed', false // Whether the first argument is a regex. ); } add_action( 'init', 'acme_register_provider' ); /** * Cached embeds live in post meta and never expire on their own. * Run this once after changing the endpoint or the markup. */ function acme_flush_embed_cache() { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_oembed_%'" ); }