繁体   English   中英

WordPress不显示| 在里面 <title> index.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM