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

Empty search with taxonomy filter not working properly

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Empty search with taxonomy filter not working properly

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • #8722
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    I think I might have a solution, at least it’s working on my test environment.

    Basically you need to put these into your active theme folder, into the functions.php file:

    [php]add_filter(‘asp_pagepost_results’, ‘asp_reorder_by_meta’, 1, 1);

    function asp_reorder_by_meta( $results ) {
    // first, get the missing CF field
    foreach ($results as $k => $r) {
    $results[$k]->m_author_name = get_post_meta($r->id, ‘author_name’, true);
    }
    // sorting by the new field with a helper funtion
    usort($results, "asp_meta_author_cmp");

    return $results;
    }

    /**
    * Performs object attribute comparison
    */
    function asp_meta_author_cmp($a, $b) {
    return strcmp($a->m_author_name, $b->m_author_name);
    }[/php]

    This does the following:
    – Connects to ajax search pro via the “asp_pagepost_results” filter
    – then gets the “author_name” meta and adds it to the m_author_name field to each result item
    – performs a sorting based on a function, comparing the m_author_name fields, which now contains the author name custom field

    I hope this helps.

    #8724
    ilariaroglieriilariaroglieri
    Participant

    It works like a charm!
    Thank you very much Ernest.
    Looking forward to the update!
    Ilaria

Viewing 2 posts - 16 through 17 (of 17 total)
  • You must be logged in to reply to this topic.