最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

the content - How to use embed_content hook?

programmeradmin0浏览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?

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?

Share Improve this question edited Sep 23, 2019 at 7:36 Star Light asked Sep 23, 2019 at 7:29 Star LightStar Light 518 bronze badges 2
  • 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 Commented Sep 23, 2019 at 7:56
  • @SallyCJ Do you have examples? I quite don't understand the 'embed excerpt'. – Star Light Commented Sep 23, 2019 at 8:44
Add a comment  | 

1 Answer 1

Reset to default 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

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

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

发布评论

评论列表(0)

  1. 暂无评论