How to use embed_content hook?

From the document of embed_content:

Prints additional content after the embed excerpt.

But I don't know which content it will print. Does it take any arguments?

Topic the-content documentation hooks Wordpress

Category Web


No, WordPress does not pass any arguments to the hook's callbacks. And you can use that hook to display something after the embed excerpt is displayed. But this is of course, if the theme is using the default embed template for post embeds — with custom template, you could, if you want to, display the entire post content.

And the embed excerpt is really an automatic or manual excerpt of the content of the embedded post — see examples below.

Code Sample

// No arguments passed to this callback.
function my_callback() {
    // Here, you can use the_xx functions like the_ID().
    echo '<p><b>This is the additional content.</b></p>';
}
add_action( 'embed_content', 'my_callback' );

Preview 1: Embedding a post having an auto-generated excerpt

enter image description here

Preview 2: Embedding a post having a defined/manual excerpt

enter image description here

So in both previews, the "This is the additional content." was added via the embed_content hook.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.