Problem with Archive page : Category listing

January 2013 WordPress Theme
GK User
Fri Mar 14, 2014 1:19 pm
Using the Archive Page, is there a way to put the Categories in order of their creation (i.e. by date)?

My news articles are in categories that have been imported from a previous site and are all named and organised by month - Subject January 2014, Subject February 2014 etc, where the subject name remains the same.

Currently when displayed in the Archive category list, they appear ordered alphabetically as Subject April 2012, Subject April 2013, Subject August 2012, Subject August 2013, Subject December 2012, Subject December 2013 etc.

I would like them to display chronologically. Is this possible?

Thanks
User avatar
Fresh Boarder

GK User
Fri Mar 14, 2014 2:25 pm
Hi,

Are you talking about Archive template page? like here: http://www.gavick.com/demo/wordpress/news/?page_id=107
or archive like category, author page etc: http://www.gavick.com/demo/wordpress/news/?m=201301
User avatar
Moderator

GK User
Fri Mar 14, 2014 3:57 pm
Hi

Sorry, I should have been clearer. The centre column on a page like this:

http://www.gavick.com/demo/wordpress/news/?page_id=107

Thanks
User avatar
Fresh Boarder

GK User
Mon Mar 17, 2014 9:42 am
Ok, now I understand, you can change it in News/template.archive.php file

in this fragment
Code: Select all
wp_list_categories(array(
                     'orderby' => 'name',
                     'show_count' => 1,
                     'title_li' => ''
                  ));

change orderby from name to e.g. ASC or DESC.
User avatar
Moderator

GK User
Mon Mar 17, 2014 12:20 pm
Hi

Thanks for your reply.

I have tried editing the file you suggest, changing orderby with alternately 'asc' and 'desc', but neither makes a change to the listing. The list is still displaying months in alphabetical order, rather than calendar year order.
User avatar
Fresh Boarder

GK User
Mon Mar 17, 2014 3:15 pm
Unfortunately there's no option to sort it by date:
http://codex.wordpress.org/Template_Tag ... categories

but please try to use this code:
Code: Select all
wp_list_categories(array(
                     'orderby' => 'ID',
                     'order' => 'DESC',
                     'show_count' => 1,
                     'title_li' => ''
                  ));
User avatar
Moderator

GK User
Mon Mar 17, 2014 7:45 pm
Hi
Thanks for your suggested code. It fixes all the most recent categories of the list into the right calendar order, so well done and thanks for your help.

Some of the earlier date category IDs must have been created out of sequence, so I don't think it's an easy fix to manually change various IDs.

Thanks again for your help.
User avatar
Fresh Boarder

GK User
Tue Mar 18, 2014 8:36 am
Yes, it works properly only if your category IDs are in right sequence, unfortunately there's no other way.
User avatar
Moderator


cron