WP Ultimate Search
[resolved] Ordering search results (5 posts)

  1. bludrop
    Posted 2 years ago #

    Is there a way to edit the sort order of the search results (so that they display in a chronological order)? It seems like they are being displayed in a random order.


  2. Bryce Corkins
    Posted 2 years ago #

    If you know a little bit about programming, the plugin supports creating a custom output template that uses a standard WordPress loop... then you can modify the result order and formatting any way you want. You can read about how to do this on the FAQ at http://mindsharelabs.com/

  3. bludrop
    Posted 2 years ago #

    I do have a custom template set up and tried a number of ways to customize the order of the loop [as well as modify another part of the output]. It didn't seem to be working the same way other loops work.

  4. Bryce Corkins
    Posted 2 years ago #

    It's a little bit different, but essentially the same concept. All of the results are stored in the $results variable. You can use var_dump($results); to see the contents. You can iterate through this array and re-order it based on the date value of the posts... there's a lot of information on google about array sorting.

    We will make this easier in the future... with options that allow you to set the default order for returned results, and eventually we want to have a way for users to re-order results as they conduct searches.

  5. bludrop
    Posted 2 years ago #


    For those interested, I used usort to sort the array, which was inserted at the top of the results custom template file.

    <?php usort( $results, create_function('$a,$b', 'return strcmp($b->post_date, $a->post_date);') ); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Ultimate Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic