I’ve followed the official documentation to create my archives page: http://codex.wordpress.org/Creating_an_Archive_Index
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.org/Creating_an_Archive_Index
It works fine exept that “is_archive() returns false when I’m viewing this page.
Any idea ?
You must be logged in to post a comment.
Because 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 usingif ( 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 asarchives.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() )