【发布时间】:2022-06-22 00:58:13
【问题描述】:
我想修改我的 wp_head。我正在使用 Yoast 插件,我想在描述元标记之后添加一个新的自定义元标记。我尝试使用此代码添加关键字标签,但在描述标签之后未显示,它显示在较低的位置 这段代码
/*Display custom meta keywords or the post excerpt */
function add_custom_meta_key(){
#Single Page Meta Description
if( is_single() ){
$key = get_post_meta( get_the_id(), 'keywords', true);
if( ! empty( $key ) ){
$meta_key = esc_html($key);
echo '<meta name="keywords" content="' . $meta_key . '" />';
}
}}
add_action( 'wpseo_head', 'add_custom_meta_key', 2 );
【问题讨论】: