Created
May 2, 2014 14:53
-
-
Save jaredatch/25b4c9fde3b2773f0c21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Creates nested date archive list for a specific category | |
* | |
* @since 1.0.0 | |
*/ | |
function ja_category_archive_list() { | |
global $post; | |
$posts = get_posts( 'posts_per_page=-1&cat=154' ); | |
$year = ''; | |
$month = ''; | |
echo '<ul class="date-archive-list">'; | |
foreach( $posts as $post ) { | |
setup_postdata( $post ); | |
if ( ucfirst( get_the_time( 'F' ) ) != $month && $month != '' ){ | |
echo '</ul></li>'; | |
} | |
if ( get_the_time( 'Y' ) != $year && $year != '' ){ | |
echo '</ul></li>'; | |
} | |
if ( get_the_time( 'Y' ) != $year ){ | |
$year = get_the_time('Y'); | |
echo '<li><h2>' . $year . '</h2><ul class="monthly-archives">'; | |
} | |
if ( ucfirst( get_the_time( 'F' ) ) != $month ){ | |
$month = ucfirst( get_the_time( 'F' ) ); | |
echo '<li><h6>' . $month . '</h6><ul>'; | |
} | |
echo '<li>'; | |
echo '<span class="date">' . get_the_time( 'jS' ) . '</span> - '; | |
echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>'; | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
wp_reset_postdata(); | |
wp_reset_query(); | |
} | |
add_action( 'genesis_entry_content', 'ja_category_archive_list' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment