Tagged: ajax search
-
AuthorPosts
-
September 7, 2021 at 4:15 pm #1319998
Hi there,
I am currently using relevanssi with the following solution: https://www.relevanssi.com/knowledge-base/indexing-taxonomy-pages/ to return search results for taxonomy terms (Product Categories and Brands).
It works fine on the Enfold search results page. But on the Ajax search, the title and link come back blank. Only the excerpt is displayed. I understand the default enfold search is based on posts only.
But is there a way for me to customize this in my child theme to add results for taxonomy terms in the Ajax search results as well? I was looking as the following thread to try to achieve this: https://kriesi.at/support/topic/ajax-search/ but I’ve not been able to get very far.
September 10, 2021 at 6:28 am #1320331Hey Rustum,
Thank you for the inquiry.
Did you use the filter from the following documentation?
This should return the Relevanssi function instead of the default get_posts function, which is limited to default posts and custom post types.
Best regards,
IsmaelSeptember 10, 2021 at 11:35 am #1320369Hi Ismael,
I have now added the above filter as per: https://kriesi.at/documentation/enfold/search/#use-relevanssi-in-search-instead-of-the-default-search and it still doesn’t fix the issue. Please note that the instruction in the above link also states “The below code is no longer required to add the Relevanssi support to your enfold theme. Please remove from your functions.php file if you have added it to the earlier version of the enfold theme.”
However, I have left the code in as per your suggestion. The issue is with the Ajax search itself. If you search for the Product Category “Brackets” for example, the Ajax search only returns the excerpt, the title and link are blank. But when you click through to search page: https://orthoemporium.zerobox.co.za/?s=brackets the title and link work as expected. So I just need to get the Title and link to be fixed in the Ajax search.
Thanks.
September 13, 2021 at 1:00 am #1320604Hi,
Thank you for the inquiry.
The title is not displaying because by default the AJAX search is using the get_the_title function, which can only retrieve post title as the name suggests. You will have to modify the functions-enfold.php file and adjust this code around line 433 and 443 in order to get the title and link of the archive pages.
433:
$link = apply_filters( 'av_custom_url', get_permalink( $post->ID ), $post );
443:
$output .= '<span class="av_ajax_search_content">'; $output .= '<span class="av_ajax_search_title">'; $output .= get_the_title($post->ID); $output .= '</span>';
You may need to use these functions.
// https://developer.wordpress.org/reference/functions/get_post_type_archive_link/
// https://developer.wordpress.org/reference/functions/get_the_archive_title/Best regards,
IsmaelSeptember 13, 2021 at 8:37 am #1320656Thanks once again Ismael,
Is it possible to make this change in my child theme’s functions.php file? if not, I will rather just disable the Ajax search as a workaround for this.September 17, 2021 at 7:40 am #1321336Hi,
You can copy the whole avia_ajax_search function in the child theme’s functions.php file, without the function_exists check. This should override original function in the parent theme.
Thank you for your patience.
Best regards,
IsmaelSeptember 20, 2021 at 2:50 pm #1321642Thanks Ismael,
All good now. Works perfectly.
September 21, 2021 at 6:28 am #1321714 -
AuthorPosts
- The topic ‘Edit default Ajax search for Taxonomy Terms’ is closed to new replies.