我目前正在使用此代码在我的wordpress主题中显示帖子/页面和博客的名称:
<title><?php wp_title(''); ?> | <?php bloginfo('name'); ?></title>
问题是索引.php看起来像这样:|博客的名称
我该如何解决这个问题?
提前感谢!
在您的functions.php
中添加
add_theme_support( 'title-tag' );
在Content-Type
元下的标题中添加,如下所示:
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
<?php
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function yourtheme_render_title() {
?>
<title><?php wp_title( ' ', true, 'right' ); ?></title>
<?php
}
add_action( 'wp_head', 'yourtheme_render_title' );
endif;
?>
在"设置"上设置博客/网页的标题后,应该可以工作。