Knowledge Base

Numbering the results

in Ajax Search Pro Tips Tags: ajax searchfilterfunctionnumberingresults

You can do all kinds of fun thing with the provided filering functions. One of them is post numbering, and it's really easy to do.

Put the following code to your themes functions.php file:

add_filter( 'asp_results', 'asp_number_results', 1, 1 );

function asp_number_results( $results ) {
  $num = 1;
  foreach ($results as $k=>$v) {
    // Modify the post title
    $results[$k]->title  = $num . ". " . $results[$k]->title;
    $num++;
  }

  return $results;
}

Enjoy!