Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search Results: Dropdown Width & Show Categories
This topic contains 4 replies, has 2 voices, and was last updated by ShawnS52 6 years, 4 months ago.
- AuthorPosts
- May 30, 2017 at 3:44 pm #13316
Hello again, I think I have just 2 final questions on setting up the search to look the way I’d like.
Through the element inspector in Chrome I’ve been able to adjust the width of the dropdown search results but I can’t figure out where to edit them in the plugin files. Here is an example of what I’d like to do, have the results dropdown width be 850px or a certain percentage: http://imgur.com/a/oxP62
Second, is it possible to change the Advanced description field to show all of a post’s categories? I had found another ticket where you provided code to functions.php to show the tags, would it be similar for categories?
Let me know if you would like me to submit these separately and thank you again for all the help!
May 30, 2017 at 4:06 pm #13319Hi!
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 :)
May 30, 2017 at 5:34 pm #13320The results box css worked great!
The Custom Filter didn’t do quite what I was looking for. For this section I would like the categories to be in place of the {descriptionfield}. Is that possible? Thanks!
// Modify the post title if ( count($cats) > 0 ) $results[$k]->content .= " ".implode(', ', $cats); }
May 30, 2017 at 8:28 pm #13324You are welcome!
To completely replace the content, just change this line in the code:
$results[$k]->content .= " ".implode(', ', $cats);
..to this:
Best,$results[$k]->content = implode(', ', $cats);
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 31, 2017 at 2:12 pm #13335This worked fine, thanks!
- AuthorPosts
You must be logged in to reply to this topic.