This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Search Results: Dropdown Width & Show Categories

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13316
    ShawnS52ShawnS52
    Participant

    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!

    #13319
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

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

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

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

    [php]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;
    }[/php]

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

    #13320
    ShawnS52ShawnS52
    Participant

    The 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!

    [code]// Modify the post title
    if ( count($cats) > 0 )
    $results[$k]->content .= " ".implode(‘, ‘, $cats);
    }[/code]

    #13324
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You are welcome!

    To completely replace the content, just change this line in the code:

    [php]$results[$k]->content .= " ".implode(‘, ‘, $cats);[/php]

    ..to this:

    [php]$results[$k]->content = implode(‘, ‘, $cats);[/php]

    #13335
    ShawnS52ShawnS52
    Participant

    This worked fine, thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.