WordPress.org

Support

Support » Plugins and Hacks » WP Ultimate Search » [Resolved] Ordering search results

[Resolved] Ordering search results

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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/

    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.

    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.

    Thanks.

    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);') ); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Ordering search results’ is closed to new replies.
Skip to toolbar