Support » Plugin: Clean My Archives » Putting archives in reverse order?

  • Resolved gorky5


    Hi. I really like this plugin. I’ve been using Clean Archives Reloaded for some time, and Clean My Archives reduced the number of queries from 3,500 (!) to around 70. Much better performance all round.

    The only reason I’m reluctant to switch, however, is because Clean My Archives displays the archives with the most recent at the top. I run a site with a lot of historical entries going back to 1926, and want the oldest to be at the top.

    Is there a way to reverse the order, other than using masses of shortcodes containing year=”xxxx”?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Justin Tadlock


    Not at the moment. However, I can add an option in for the next version. It shouldn’t be too hard. Let me see if I have some time this afternoon to push out an update.

    Thank you Justin – that would be great. If it can happen I’ll send a donation your way.

    Plugin Author Justin Tadlock


    I just pushed version 1.1.0 to the repo. It should be live momentarily. You should be able to reverse the order with:

    [clean-my-archives order="ASC"]

    Thank you! That worked perfectly, and it’s very much appreciated. Really good of you to help. Donation sent as promised.

    While I’m here, I noticed on your own archive page you have a line saying: “You can browse through 1402 posts containing 420,552 words.” Is there a code snippet I can use for including the post and word counts on my own site? Sorry if this isn’t the right place to ask.

    Plugin Author Justin Tadlock


    It’s a little custom code for 2 shortcodes I dropped in a custom plugin (could put in your theme’s functions.php too). They’re really basic. You’re more than welcome to use them. I can’t guarantee the quality or that these will work great.

    The shortcodes are [post-count] (counts all published posts of all post types) and [post-word-count] (counts all words).

    Here’s the code:

    add_action( 'init', 'my_register_shortcodes' );
    function my_register_shortcodes() {
    	add_shortcode( 'post-count', 'my_post_count_shortcode' );
    	add_shortcode( 'post-word-count', 'my_post_word_count_shortcode' );
    function my_post_count_shortcode() {
    	global $wpdb;
    	return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'" );
    function my_post_word_count_shortcode() {
    	global $wpdb;
    	$words = $wpdb->get_results( "SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish'" );
    	if ( $words ) {
    		foreach ($words as $word) {
    			$post = strip_tags($word->post_content);
    			$post = explode(' ', $post);
    			$count = count($post);
    			$totalcount = $count + $oldcount;
    			$oldcount = $totalcount;
    	return !empty( $totalcount ) ? number_format( $totalcount ) : 0;

    I use it like so in my page editor:

    Looking for something specific? Well, you may have come to the rig...*ugh* somewhere near the right place.  You can browse through <strong>[post-count]</strong> posts containing <strong>[post-word-count]</strong> words.  You can also view the archives by <a href="/tags" title="Tags Archive"> tag</a> or <a href="/topics" title="Topics Archive"> topic</a>.

    Thank you again! You’re a star. I’ll give these a try later today.

    Hi there, your Archives plugin is brilliant. Just plain and simple and brilliant.

    I’m inexperienced on WP and want to know how to make my Archives look like your Site Archives page demo. http ://

    Can I style my Archives to look exactly like that?



Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Putting archives in reverse order?’ is closed to new replies.