admin管理员组文章数量:1289944
I've followed the official documentation to create my archives page:
It works fine exept that "is_archive() returns false when I'm viewing this page.
Any idea ?
I've followed the official documentation to create my archives page: http://codex.wordpress/Creating_an_Archive_Index
It works fine exept that "is_archive() returns false when I'm viewing this page.
Any idea ?
Share Improve this question asked Jul 11, 2011 at 19:18 koskozkoskoz 2451 gold badge4 silver badges7 bronze badges2 Answers
Reset to default 6Because an "archives" Page is not an archive index of blog Posts, but rather a Page.
An "archives" page is simply a custom Page template, which applies to a static Page.
The is_archive()
conditional returns true if an archive index is being displayed. An archive index page displays Posts, not static Pages.
EDIT
Instead of using if ( is_archive() )
, try using if ( is_page( 'archives' ) )
(assuming you've named your static Page Archives).
Alternately, you could use if ( is_page_template( 'archives.php' ) )
(assuming you've named your template file as archives.php
).
The above solutions didn't work for me because I was doing this inside the loop. Instead I checked !is_single() to determine if I was on the post or the index :
if ( 'post' == $ptype && !is_single() )
本文标签: isarchive() returns false on the archives page
版权声明:本文标题:is_archive() returns false on the archives page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741439058a2378807.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论