SHOW:
|
|
- or go back to the newest paste.
1 | <div class="accordionContent"> | |
2 | - | <ul class="sub-menu1"><?php |
2 | + | <ul class="sub-menu1"> |
3 | - | $y = date( 'Y' ); // The current year. |
3 | + | <?php |
4 | - | |
4 | + | $y = date( 'Y' ); // The current year. |
5 | - | while ( $y > 2000 ) { // Pick a reasonable year you want this loop to end at, to save your server some time. |
5 | + | while ( $y > 2000 ) { // Pick a reasonable year you want this loop to end at, to save your server some time. |
6 | - | |
6 | + | $m = 12; // For December |
7 | - | $m = 12; // For December |
7 | + | while ( $m > 0 ) { |
8 | - | while ( $m > 0 ) { |
8 | + | $args = array( |
9 | - | |
9 | + | 'posts_per_page' => -1, |
10 | - | $args = array( |
10 | + | 'cat' => 7, |
11 | - | 'posts_per_page' => -1, |
11 | + | 'year' => $y, |
12 | - | 'cat' => 7, |
12 | + | 'monthnum' => $m |
13 | - | 'year' => $y, |
13 | + | ); |
14 | - | 'monthnum' => $m |
14 | + | $cat_q = new WP_Query( $args ); |
15 | - | ); |
15 | + | if ( $cat_q->have_posts() ) { |
16 | - | $cat_q = new WP_Query( $args ); |
16 | + | $p = 0; |
17 | - | if ( $cat_q->have_posts() ) { |
17 | + | while ( $cat_q->have_posts() ) { |
18 | - | //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. |
18 | + | $cat_q->the_post(); |
19 | - | $p = 0; |
19 | + | $p++; |
20 | - | while ( $cat_q->have_posts() ) { |
20 | + | } |
21 | - | $cat_q->the_post(); |
21 | + | $monthName = date( 'F', mktime( 0, 0, 0, $m, 10 ) ); |
22 | - | $p++; |
22 | + | ?> |
23 | <li> | |
24 | - | $monthNum = $m; |
24 | + | <a href="<?php bloginfo( 'url' ); ?>/YOUR-PAGE-SLUG?month=<?php echo $m; ?>&year=<?php echo $y; ?>&cat=7"><?php echo $monthName.' '.$y.'('.$p.')'; ?></a> |
25 | - | $monthName = date("F", mktime(0, 0, 0, $monthNum, 10)); |
25 | + | </li> |
26 | - | echo '<li><a href="2956?month='; |
26 | + | <?php |
27 | - | echo $m; |
27 | + | } |
28 | - | echo '&year='; |
28 | + | wp_reset_query(); |
29 | - | echo $y; |
29 | + | $m--; |
30 | - | echo '&cat=7">'; |
30 | + | |
31 | - | echo $monthName; |
31 | + | $y--; |
32 | - | echo ' '; |
32 | + | } |
33 | - | echo $y; |
33 | + | ?> |
34 | - | echo '('; |
34 | + | </ul> |
35 | - | echo $p; |
35 | + | </div> |