最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Website Title Not Showing in Browser TabTitle Tag Empty in Page Source

programmeradmin1浏览0评论

I have set my WordPress' Website title and tagline in the settings, but it's not showing in any browser tab. It only shows the website URL in the tab. When I check the source code, the tag is blank

I have checked my theme's header.php and the code is

<title><?php wp_title(''); ?> 
        <?php if ( is_single() ) { ?> <?php } ?> 
        <?php if ( is_page() ) { ?> <?php } ?> 
        <?php if ( is_category() ) { ?> <?php } ?>
        <?php if ( is_search() ) { ?> <?php } ?>
        <?php if ( is_404() ) { ?> <?php } ?>
        </title>

I have also tried <title><?php wp_title('|', true, 'right'); ?></title>

All other files have the get header code. Does anyone have any suggestions? I think it's in the theme files because when I activate another theme, the title works.

I have set my WordPress' Website title and tagline in the settings, but it's not showing in any browser tab. It only shows the website URL in the tab. When I check the source code, the tag is blank

I have checked my theme's header.php and the code is

<title><?php wp_title(''); ?> 
        <?php if ( is_single() ) { ?> <?php } ?> 
        <?php if ( is_page() ) { ?> <?php } ?> 
        <?php if ( is_category() ) { ?> <?php } ?>
        <?php if ( is_search() ) { ?> <?php } ?>
        <?php if ( is_404() ) { ?> <?php } ?>
        </title>

I have also tried <title><?php wp_title('|', true, 'right'); ?></title>

All other files have the get header code. Does anyone have any suggestions? I think it's in the theme files because when I activate another theme, the title works.

Share Improve this question asked Feb 4 at 23:01 Maddie's FansitesMaddie's Fansites 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

It looks like your header.php is using wp_title(''), which is deprecated and may not return anything in some cases. Also, the way it's structured, it's not properly appending the site title.

Try replacing your <title> tag with the following code:

<title><?php bloginfo('name'); ?><?php wp_title('|', true, 'left'); ?></title>

Or, if you're using a newer version of WordPress, use:

<title><?php echo get_the_title() . ' | ' . get_bloginfo('name'); ?></title>
发布评论

评论列表(0)

  1. 暂无评论