Reply To: Search Results: Dropdown Width & Show Categories

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search Results: Dropdown Width & Show Categories Reply To: Search Results: Dropdown Width & Show Categories

#13319

Ernest Marcinko
Keymaster

Hi!

1. I would not recommend making direct change to the plugin files, instead use this custom CSS code:

div[id*=ajaxsearchprores] {
    width: 850px !important;
}

2. To display all categories, you will need a custom filter. Based on this knowledge-base example, this code should do the trick:

add_filter( 'asp_results', 'asp_add_category_titles', 1, 1 );
 
function asp_add_category_titles( $results ) {
  foreach ($results as $k=>$v) {
 
    // Get the post categories
    $post_categories = wp_get_post_categories( $results[$k]->id );
    $cats = array();
 
    // Concatenate category names to the $cats variable
    foreach($post_categories as $c){
        $cat = get_category( $c );
        $cats[] = $cat->name;
    }                
 
    // Modify the post title
    if ( count($cats) > 0 )
      $results[$k]->content  .= " ".implode(', ', $cats);
  }
 
  return $pageposts;
}

I have not tested this code, so please be careful!

Best,
Ernest Marcinko

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