Reply To: Customizing Suggested phrases layout

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Customizing Suggested phrases layout Reply To: Customizing Suggested phrases layout

#6755
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

There is no option for that, but here is a filter I quickly put together:

add_filter("asp_results", "asp_top_keywords");

function asp_top_keywords( $results, $id ) {
  $count = 20; // How many keywords?

  if ( !isset($results['nores']) ) return $results;

  global $wpdb;
  $keywords = array();
  
  $_keywords = $wpdb->get_results("
    SELECT keyword FROM ".$wpdb->base_prefix."ajaxsearchpro_statistics 
    ORDER BY num desc LIMIT " . $count, ARRAY_A);
  
  foreach($_keywords as $k=>$v) {
    $keywords[] = $v['keyword'];
  }
  
  $results['keywords'] = $keywords;
  
  return $results;

}

Add this to the functions.php file in your active themes folder. Before using this, don’t forget to turn on the search statistics on the Search Statistics submenu. It will not work without it.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)