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