Support » Plugin: Annual Archive » Sorting ungrouped lists (alpha, postbypost)

  • Resolved gazebotime

    (@gazebotime)


    Love this plugin. But am stumped on sorting.
    Is the “order” attribute supposed to work on ungrouped lists (type=”postbypost” or “alpha”)? When sorting by title, both of these shortcodes result in lists of ascending (A to Z) order:
    [archives type=”alpha” order=”ASC”]
    [archives type=”alpha” order=”DESC”]
    I get the same problem sorting by date. Both of these shortcodes result in descending (newest to oldest) posts:
    [archives type=”postbypost” order=”ASC”]
    [archives type=”postbypost” order=”DESC”]
    Is this a known issue or am I doing something wrong? Is it a feature available in PRO version? I’m using Annual Archive version 1.4.10.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor twinpictures

    (@twinpictures)

    You are correct. According to the WordPress codex for wp_get_archives function the type attribute will override the order attribute for postbypost and alpha:

    (string) Type of archive to retrieve. Accepts ‘daily’, ‘weekly’, ‘monthly’, ‘yearly’, ‘postbypost’, or ‘alpha’. Both ‘postbypost’ and ‘alpha’ display the same archive link list as well as post titles instead of displaying dates. The difference between the two is that ‘alpha’ will order by post title and ‘postbypost’ will order by post date. Default ‘monthly’.

    https://developer.wordpress.org/reference/functions/wp_get_archives/

    We’ll look into a workaround for you…

    Plugin Contributor twinpictures

    (@twinpictures)

    After looking at the wp_get_archive function deeper, it seems the order is being hard-coded as “post_title ASC”:

    
    ...
    } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) { 
          $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
    ...
    
    Plugin Contributor twinpictures

    (@twinpictures)

    We have added the ability to list alpha and postbypost archives using archive-pro-matic. Here is a demo of how to order these types of archives.

    This is not possible using Annual Archive, as it uses only the wp_get_archive function.

    Please let us know if you have any questions, or if we can mark this this issue as resolved.

    Plugin Contributor twinpictures

    (@twinpictures)

    Issue marked as resolved.

    Wow. You know how to earn a customer. I’m upgrading to archive-pro-matic.

    Plugin Contributor twinpictures

    (@twinpictures)

    Fantastic! We’ll send the update to you before it’s released next Tuesday.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sorting ungrouped lists (alpha, postbypost)’ is closed to new replies.