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++;
- }
- ?>
- <li>
- <a href="<?php bloginfo( 'url' ); ?>/YOUR-PAGE-SLUG/?month=<?php echo $m; ?>&year=<?php echo $y; ?>&cat=7"><?php echo $m.$y.'('.$p.')'; ?></a>
- </li>
- <?php
- }
- wp_reset_query();
- $m--;
- }
- $y--;
- }
- ?>
- </ul>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement