Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Empty search with taxonomy filter not working properly
This topic contains 16 replies, has 2 voices, and was last updated by ilariaroglieri 7 years ago.
- AuthorPosts
- May 17, 2016 at 2:37 pm #8722
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:
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); }
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 fieldI hope this helps.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 17, 2016 at 7:19 pm #8724It works like a charm!
Thank you very much Ernest.
Looking forward to the update!
Ilaria - AuthorPosts
You must be logged in to reply to this topic.