• Hi,

    I’m trying to have an archive thing running when people use url like

    http://127.0.0.1/wordpress/2015/07/09/

    The thing is, when the specified day (or month, or year) contains posts, it works, and it uses date.php (or archive.php, i tried both)

    But if the specified day (or month, or year) contains no post, it will default to index.php, thus not providing the “No post were written at this period” message that should be displayed (set in date.php)

    I tried put a is_date() or is_archive() conditional tag inside index.php, but it seems is_date() and is_archive() both returns 0 when on a “date” page without posts.

    I tried putting

    <?php if (is_home())
    			{
    			echo 'is_home' ;
    			}
    		?>
    		<?php if (is_front_page())
    			{
    			echo 'is_front_page' ;
    			}
    		?>
    		<?php if (is_single())
    			{
    			echo 'is_single' ;
    			}
    		?>
    		<?php if (is_category())
    			{
    			echo 'is_category' ;
    			}
    		?>
    		<?php if (is_tag())
    			{
    			echo 'is_tag' ;
    			}
    		?>
    		<?php if (is_date())
    			{
    			echo 'is_date' ;
    			}
    		?>
    		<?php if (is_archive())
    			{
    			echo 'is_archive' ;
    			}
    		?>
    				<?php if (is_page())
    			{
    			echo 'is_page' ;
    			}
    		?>

    in my footer

    But it returns NOTHING (wtf) on 2015/09/ (no posts), but returns is_date and is_archive on /2015

    Is that normal?
    If not, how can i fix is_date() being false on date page containing no post?

Viewing 1 replies (of 1 total)
  • What’s happening here is that if there are no posts in a particular month and year combination, WordPress never makes it that far in the template hierarchy; instead, it 404s. (If you have a 404.php in your theme, you’ll see that content; otherwise, it will default to index.php.) And is_date() will never be true in index.php, because WordPress knows that index.php isn’t a date-based archive page, even if you were pseudo-redirected there.

Viewing 1 replies (of 1 total)

The topic ‘is_date() acting strange’ is closed to new replies.