WordPress wp_title 在索引页面上是空白的 [英] WordPress wp_title blank on index page

查看:34
本文介绍了WordPress wp_title 在索引页面上是空白的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 WordPress 的新手,刚刚安装了 3.3.1 版.

I'm new to WordPress and just installed version 3.3.1.

我对这个问题进行了一些谷歌搜索并找到了一些答案,但它们与 2.7 版相关并且已经使用了 2-3 年.

I did some googling regarding this question and found some answers but they were relevant to version 2.7 and were 2-3 years old.

基本上,wp_title 函数在每个页面上都能正常工作,除了我的主页返回空白并且我没有任何标题.我可以硬编码标题,但我宁愿不这样做.

Basically, the wp_title function works fine on every page except my home page where it returns blank and I get no title whatsoever. I could just hard code the title in but I'd rather not do that.

有罪的代码行:

<title><?php wp_title ( '| So Fresh n\' So Clean', true,'right' ); ?></title>

我找不到关于 3.3.1 中发生的这个问题的任何信息,很明显我做错了什么.

I couldn't find anything regarding this problem happening in 3.3.1 so clearly I've done something wrong.

推荐答案

这是我从 Codex 中读到的内容:

Here's is what I read from Codex:

如果您使用带有自定义循环和内容的自定义主页,您将有一个空的 wp_title.这是一个巧妙的技巧来添加主页上 wp_title 位置的描述/标语:

If you are using a custom homepage with custom loops and stuff, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage:

<title><?php bloginfo('name'); ?> | <?php is_front_page() ? bloginfo('description') : wp_title(''); ?></title>

所以使用 is_front_page() 来获取首页的标题,就像上面代码中建议的那样.

So use is_front_page() to get the title on homepage, the way it is suggested in above code.

这篇关于WordPress wp_title 在索引页面上是空白的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆