This topic contains 16 replies, has 2 voices, and was last updated by ilariaroglieri 7 years, 11 months ago.
You must be logged in to reply to this topic.
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, 11 months ago.
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 field
I hope this helps.
Best,It works like a charm!
Thank you very much Ernest.
Looking forward to the update!
Ilaria
You must be logged in to reply to this topic.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |