Support » Plugin: Extra Shortcodes » [extra_archives type=”postbypost” order=”ASC”]

  • Resolved pmcjones

    (@pmcjones)


    I tried [extra_archives type=”postbypost” order=”ASC”], hoping to generate an archive index of all posts in ascending date order, but apparently the order=”ASC” parameter is ignored in this case. Was this an intentional part of the design?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I just looked at the source to wp_get_archives(), and apparently postbypost ignores order:

    } elseif ( ( ‘postbypost’ == $r[‘type’] ) || (‘alpha’ == $r[‘type’] ) ) {
    $orderby = ( ‘alpha’ == $r[‘type’] ) ? ‘post_title ASC ‘ : ‘post_date DESC, ID DESC ‘;
    $query = “SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit”;

    I wonder if the WordPress maintainers would consider a patch like this to wp_get_archives:

    .../wp-includes % diff -c general-template.php general-template.php-PATCHED
    *** general-template.php	Thu Dec 13 03:56:14 2018
    --- general-template.php-PATCHED	Wed Dec 19 10:10:24 2018
    ***************
    *** 1873,1878 ****
    --- 1873,1879 ----
      			wp_cache_set( $key, $results, 'posts' );
      		}
      		if ( $results ) {
    + 		        if ( $order == 'ASC' ) $results = array_reverse( $results );
      			foreach ( (array) $results as $result ) {
      				if ( $result->post_date != '0000-00-00 00:00:00' ) {
      					$url = get_permalink( $result );
    • This reply was modified 11 months, 4 weeks ago by pmcjones.
    • This reply was modified 11 months, 4 weeks ago by pmcjones.

    It turns out the Annual Archive plugin (https://wordpress.org/plugins/anual-archive/) implements a post_order parameter that works with postbypost. So this shortcode solved my problem:

    [archives type=’postbypost’ post_order=’asc’]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[extra_archives type=”postbypost” order=”ASC”]’ is closed to new replies.