Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="accordionContent">
- <ul class="sub-menu1"><?php
- $y = date( 'Y' ); // The current year.
- while ( $y > 2000 ) { // Pick a reasonable year you want this loop to end at, to save your server some time.
- $m = 12; // For December
- while ( $m > 0 ) {
- $args = array(
- 'posts_per_page' => -1,
- 'cat' => 7,
- 'year' => $y,
- 'monthnum' => $m
- );
- $cat_q = new WP_Query( $args );
- if ( $cat_q->have_posts() ) {
- //echo $m; // This will only echo the month number, but you can figure out how to substitute it for the month's name, I'm sure.
- $p = 0;
- while ( $cat_q->have_posts() ) {
- $cat_q->the_post();
- $p++;
- }
- $monthNum = $m;
- $monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
- echo '<li><a href="2956?month=';
- echo $m;
- echo '&year=';
- echo $y;
- echo '&cat=7">';
- echo $monthName;
- echo ' ';
- echo $y;
- echo '(';
- echo $p;
- echo ')';
- echo '</a></li>';
- }
- wp_reset_query();
- $m--;
- }
- $y--;
- }
- ?>
- </ul>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement