Sorting the Directory Results in Alphabetical order

I have many items entered in the Directory. Once I click on a main category, it doesn't appear there is much method to how the information is sorted. Looks like maybe they are sorted by post date? It is just a bunch of listings with no real way to sort through them.

Wouldn't it make more sense to order them either in alpha order or by sub-category? How do we accomplish this?

http://visitrockwall.com/business-directory

  • Vaughan
    • Support/SLS MockingJay

    hiya

    thanks for posting.

    i've been looking through the code but unable to find a solution, though i've not checked everywhere, i'm sure this could probably be done using a child directory theme with a custom query, however that's a bit more custom work.

    I'll flag the developer for some feedback. maybe he knows a quick solution.

    thanks.

  • Seth
    • Flash Drive

    I was able to sort directory listings by changing the $query_args array in /wp-content/plugins/directory/ui-front/general/page-listings.php

    For example, I can sort listing results by a custom field (in my case, the custom field ID is _ct_text_51d69bbb64ecd, which corresponds to a custom field of Last Name) with the code:

    $query_args = array(
    'post_type' => 'directory_listing',
    'post_status' => 'publish',
    'paged' => $paged,
    'orderby' => 'meta_value',  //meta_value_num for numbers meta_value for strings
    'order' => 'ASC',  //ASC or DESC
    'meta_key' => '_ct_text_51d69bbb64ecd',  //the meta field id
    );

    The only thing added to the original code is the orderby, order, and meta_key arguments.

    Note, however, that because of the location of the php file, future updates to the plugin may over-write this code, so you should consider putting it in your theme directly.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.