如何将元数据从 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";
}