Do_Shortcode not working for Embed

Simply put </code> is not a regular shortcode. Most of the time it does nothing. What happens when post content goes through <code>the_content</code> filter is following:</p>

<ol>
<li><p><code>[emded]</code> is currently registered to do nothing ( <code>__return_false()</code> )</p></li>
<li><p><code>WP_Embed->run_shortcode()</code> filter runs with low <code>8</code> priority</p></li>
<li>all shortcodes are disabled</li>
<li><code></code> is registered to <code>WP_Embed->shortocde()</code></li>
<li><code>do_shortcode()</code> executes on content (only doing embeds, since rest is disabled)</li>
<li>shortcodes are restored to original state, <code></code> is back to being useless.</li>
</ol>

<p>So my quick guess for something to try would be:</p>

<pre><code>global $wp_embed;

echo $wp_embed->run_shortcode('whatever');

But note that there is also caching involved (embedding results are saved to custom field of the post, otherwise it would need to make HTTP request every time) and you are likely breaking that, unless you are doing it inside loop and close to where it normally works. Maybe even then.

Leave a Comment