0

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?

  • No, the hook doesn't pass any arguments to the hook's callbacks. And you can use that hook to display something after the embed excerpt is displayed. – Sally CJ Sep 23 '19 at 7:56
  • @SallyCJ Do you have examples? I quite don't understand the 'embed excerpt'. – Star Light Sep 23 '19 at 8:44
1

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.

  • This answer should be add to Wordpress codex. – Star Light Sep 23 '19 at 10:12
  • I'm glad it helped you. :) – Sally CJ Sep 23 '19 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.