Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1491908

    Hello! We are using the “Hivepress” directory plugin to build a directory of law firms. The website itself is built with Enfold.

    The problem:
    When using the built-in search functions or filtering functions on the Hivepress generated webpages, i.e. for searching Law firms by custom fields such as location, speciality, or category, the website redirects to a generic (Enfold) “Nothing found” result page, instead of using the Hivepress result page with listings. So each user search on the Hivepress directory for listings will result in an Enfold standard page that says “Nothing found – Would you like to try a new search?” Obviously because the standard WordPress search only searches for keywords in titles and texts, but has no clue about the Hivepress custom fields for listings.

    I do not know why this happens – when I debug the website by switching to a generic theme, such as “Twenty Twentyfive”, the Hivepress search works fine. Only when activating the Enfold theme it does not.

    So my question is: Does Enfold actively grab search requests and redirects them to its own result page? This would explain why Hivepress never kicks in with its own result page. And if this is true, is there any way to keep Enfold from doing that? Deactivate some code?

    If we don’t find a solution, we will have to re-create the whole website with another theme, just to become compatible with Hivepress. I would hate to do that, as it has taken us almost 2 months to build the site with Enfold.

    Any ideas highly appreciated! I can also upload screenshots or offer admin access to the dev website, if needed!
    Cheers, Sebastian

    #1491911

    Hey sescha,

    Thank you for the inquiry.

    Is it working correctly when using the default WordPress search widget instead of the theme’s AJAX search? You can test this by adding a Search widget in the Appearance > Widgets panel.

    Another option is to use the avf_ajax_search_query filter to adjust the default query so it retrieves listings based on their custom fields. You may need to contact hivepress for the correct query parameters.

    Let us know the result.

    Best regards,
    Ismael

    #1491951

    Thanks for your input. And yes, I know the issue was caused by the Enfold theme, I had already tried debugging with fallback themes where the Hivepress listing search worked just fine. Unfortunately, we had to stick with the Enfold theme as the whole website was already fully built with it and its ALB visual editor, making it impossible to switch themes just for Hivepress compatibility.

    However, yesterday I took a full day to investigate the Enfold theme files, and I am happy to report that I have found the cause, and thus could fix the problem. Enfold developers might want to read on to understand and fix this potentially problematic code, as it might cause incompatibility issues with not just Hivepress but also other WordPress extensions that use their own search logic.

    The file causing the Hivepress search problem is found in the Enfold theme file structure, namely

    /themes/enfold/includes/helper-template-logic.php

    In this file exists a function called “avia_search_query_filter”, starting around line 37. Its purpose is to “make sure that empty searches are sent to the search page as well”. Empty searches would mean standard text searches without a keyword (search term).

    Unfortunately, this function does not check for custom post_types, it just addresses all searches. The URL https://wiras.dora.group/?post_type=hp_listing&s= should definitely display the search results for the custom “Listing” post type, which is Hivepresses’ own custom post_type (since the parameter is in the URL after clicking Search), and not be treated as a standard text search.

    The problem is that most Hivepress searches would be considered “empty” searches as they don’t have a keyword parameter, but are searches by checkbox, select menue or radio button values (these are generated by the listings “custom fields”). Thus, the above mentioned function of the Enfold theme hijacks those searches and instead of handing them over to Hivepress, redirects them to the themes’ own “Nothing found” search result page.

    All I had to do now is to comment out the whole function in the file “helper-template-logic.php”, starting from line 41 until line 66:

    41 if(!function_exists(‘avia_search_query_filter’))
    42 {
    43 function avia_search_query_filter($query)
    […]
    64 add_filter(‘pre_get_posts’, ‘avia_search_query_filter’);
    65 }

    For now this works for us, as we don’t use a standard text search on the site anyway. We just have to be careful when updating the theme.

    You might consider finetuning your function to check for “custom post types” and exclude them from the search redirecting, as it seems your current approach is a bit too general and has the potential to hijack other plugins custom search patterns.

    Best regards,
    Sebastian

    #1491968

    Hi,

    Glad to know that you’ve found the issue. To override the current filter, you can use the remove_filter function so you can define your own.

    https://developer.wordpress.org/reference/functions/remove_filter/

    Please feel free to open another thread if you have more questions.

    Have a nice day.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Problems with Hivepress plugin / Does Enfold redirect searches?’ is closed to new replies.