Code Samples /

Date Archives

The code below will display an archive of posts by date (day/month/year).

archive.php
<?php
get_header();
         	
$year = get_the_date( 'Y' );
$month = get_the_date( 'm' );
$day = get_the_date( 'd' );	
 
if ( is_year() ) {
   echo '<h1>' . the_date( 'Y' ) . '</h1>';
   echo do_shortcode( '[ajax_load_more year="' . $year . '"]' ); 
}  
   
if ( is_month() ) {
   echo '<h1>'. the_date( 'F, Y' ) .'</h1>';
   echo do_shortcode( '[ajax_load_more year="' . $year . '" month="' . $month . '"]' ); 
}  
 
if ( is_day() ) {
   echo '<h1>'. the_date( 'F jS, Y' ) .'</h1>';
   echo do_shortcode( '[ajax_load_more  year="' . $year . '" month="' . $month . '" day="' . $day . '"]' ); 
}  
 
get_footer(); 
PHP

« Back to Code Samples