Support » Themes and Templates » Single Category Archive

  • I am trying to create a single category archive in my sidebar widget. I have tweaked some code I found, but I don’t want it to show the current month in the archives. Not sure what to change to accomplish that.

    		            global $wpdb, $wp_locale;
                        $query = "select YEAR(post_date) AS <code>year</code>, MONTH(post_date) AS <code>month</code>, count(ID) as posts from $wpdb->posts,  $wpdb->term_taxonomy, $wpdb->term_relationships
                            WHERE $wpdb->posts.post_status = 'publish'
                            AND $wpdb->posts.post_type = 'post'
                            AND $wpdb->term_taxonomy.term_id = 9
                            AND $wpdb->posts.ID = $wpdb->term_relationships.object_id
                            AND $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
                         GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
                         $arcresults = $wpdb->get_results($query);
                        foreach ($arcresults as $arcresult):
                        $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);?>
                        <li><a href="<?php bloginfo('url') ?>/<?php echo $arcresult->year; ?>/<?php echo str_pad($arcresult->month, 2, '0', STR_PAD_LEFT); ?>/<?php echo "?cat=9";  ?>"><?php echo $text;  ?> </li>
                          <?php endforeach; ?>

    Any help would be appreciated.

  • The topic ‘Single Category Archive’ is closed to new replies.