Directory Listings Sorted

I have a website with the Directory plugin.

On the page listings the listings do not appear to be in any order.

Is there a way to sort these?

I asked a similar question about sorting by a Custom Field but that did not end up being what the client wants.

They just want to sort by the Title of the listing.

Here's the website and page:

  • aecnu
    • WP Unicorn

    Greetings tecdac,

    Thank you for this great question though I admit I do not know the answer directly.

    Therefore I shall ask the lead developer with his invaluable insight into this plugin for his advice/advise us to how this may be done.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Thank you for being a WPMU Dev Member!

    Cheers, Joe

  • Arnold
    • El Macho WP

    Hi tecdac,

    :slight_smile: Sorry but I gotta sleep sometime.

    The default sorting is the same as all post, most recent publication date first.

    If you want to change that you would need to change the loop query to sort on whatever field you want. In this case you would need to add 'orderby' => 'title' to the query arguments.

    In the current version this would be in the core.php and be a pain to find and change. Part of the work I'm doing on Directory is externalizing the loops so they are easier to customize. I've attached a beta version you can try out. The changes would be made in ui-front/general/page-listings.php

  • tecdac
    • Flash Drive

    This will be a fairly small directory so this "The default sorting is the same as all post, most recent publication date first." in Arnold's answer above became the answer to my question.

    Just manipulate the published date on each listing so the listings are in the order you want them.

    Maybe a bit hokey but the user asked me already if there was a way to override any sort put into place.

    Thanks, Arnold.


  • 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.