首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Wordpress oembed json链接中删除author和author_url

从Wordpress oembed json链接中删除author和author_url
EN

Stack Overflow用户
提问于 2019-02-27 22:36:03
回答 1查看 1K关注 0票数 4

我注意到Wordpress会在header中生成2个链接。它们包含一些oembed参数。

这看起来像这样:

代码语言:javascript
复制
<link rel="alternate" type="application/json+oembed" href="......">
<link rel="alternate" type="text/xml+oembed" href=".......">

{
      "version": "1.0",
      "provider_name": "Website Name",
      "provider_url": "http://example.com",
      "author_name": "admin",
      "author_url": "http://example.com/author/admin/",
      "title": "",
      "type": "rich",
      "width": 600,
      "height": 338,
      "html": "long string of html"
    }

我知道我可以禁用这些链接,但我想保留它们,只删除author_name和author_url。

有什么办法可以做到这一点吗?

希望你能帮上忙。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-09-21 03:48:17

保留rel链接并过滤数组数据:

代码语言:javascript
复制
function filter_oembed_response_data_author( $data, $post, $width, $height ) {
    //print_r($data);
    unset($data['author_name']);
    unset($data['author_url']);
    return $data;
};
add_filter( 'oembed_response_data', 'filter_oembed_response_data_author', 10, 4 );

您可以转到您的一个rel链接,取消注释print_r,并通过操作$data数组来添加、编辑或删除条目。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54907869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档