SO网友:Frank P. Walentynowicz
是的,是的。将此代码添加到主题functions.php
:
function my_wp_head_action() {
// must be a single post/page
if( is_page() || is_single() ) {
$post = get_post();
$author = get_user_option( \'display_name\', $post->post_author );
echo \'<meta name="author" content="\'. esc_attr( $author ) .\'" />\';
}
}
add_action( \'wp_head\', \'my_wp_head_action\' );
或者,如果你真的想在
<head> ... </head>
块,修改
header.php
模板,并将此代码放在所需的位置:
<?php
if( is_page() || is_single() ) {
$post = get_post();
$author = get_user_option( \'display_name\', $post->post_author );
echo \'<meta name="author" content="\'. esc_attr( $author ) .\'" />\';
} ?>