如何将元数据从 wordpress 插件添加到页面的头部? [英] How can I add meta data to the head section of the page from a wordpress plugin?

查看:25
本文介绍了如何将元数据从 wordpress 插件添加到页面的头部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 wordpress 插件,需要在我的插件中向页面的 head 部分添加一些元标记.有谁知道我会怎么做?

I am writing a wordpress plugin and need to add some meta tags to the head section of the page from within my plugin. Does anyone know how I would do this?

谢谢

推荐答案

是的,您可以像这样向 wp_head 添加动作钩子:

Yes you can add an action hook to wp_head like this:

add_action('wp_head', myCallbackToAddMeta);
function myCallbacktoAddMeta(){
  echo "\t<meta name='keywords' content='$contents' />\n";
}

这篇关于如何将元数据从 wordpress 插件添加到页面的头部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆