Video embeds work in backend, but are not parsed in frontend

I’ve just looked at the source of the WP_Embed class, and it appears they are not actually registering a shortcode, but hooking into the the_content filter.

Change your code to

$content_desktop = apply_filters("the_content", get_the_content());

or manually trigger their filter with something like

$content_desktop = WP_Embed::run_shortcode(get_the_content());

or, if you prefer to have an object:

$myembeds = new WP_Embed;
$content_desktop = $myembeds->run_shortcode(get_the_content());

See also WP_Embed::run_shortcode in the codex, and the source code of class-wp-embed.php.

Leave a Comment