![](/img/trans.png)
[英]Wordpress: Include a post by title into theme index.php and don't display it in single.php
[英]Wordpress don't show | in the <title> attribute on the index.php
我目前正在使用此代码在我的wordpress主题中显示帖子/页面的名称和博客的名称:
<title><?php wp_title(''); ?> | <?php bloginfo('name'); ?></title>
问题是index.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;
?>
在“设置”上设置博客/网页的标题后,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.