• Resolved Anonymous User 17275278

    (@anonymized-17275278)


    Hello,
    I’m currently using Relevanssi Premium for my WordPress searches but I’m experiencing some issues with custom fields, specifically ACF Repeaters (subfields).
    I’ve read that Relevanssi supports wildcards in its query but I can’t get it to work properly.

    This is my custom search page: https://pastebin.com/D5ghcgSS

    The query works like a charm until I uncomment those custom fields inside the meta query.
    Thank you for your help, this would be life saving!

    Extra question: is it possible to get all posts when ‘s’ parameter (custom fields will be in a if statement later) is empty? and again, is it possible to get posts filtered by meta query even though ‘s’ parameter is empty?

    • This topic was modified 5 years, 5 months ago by Anonymous User 17275278.
    • This topic was modified 5 years, 5 months ago by Anonymous User 17275278.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Anonymous User 17275278

    (@anonymized-17275278)

    UPDATE: Wildcard character results to be, in the final query, a random string between brackets for some reason so I managed to fix this using another character $ and replacing it with % in my function.php using relevanssi_where hook.

    This is the final code, if you need it, just replace your field name:

    function add_cond_to_where($where) { 
    
    	$where = str_replace("meta_key = 'repeatername_$", "meta_key LIKE 'repeatername_%", $where);
    	$where = str_replace("meta_key = 'secondrepeatername_$", "meta_key LIKE 'secondrepeatername_%", $where);
    	// ... more fields
    
    	return $where; 
    
    } add_filter('relevanssi_where', 'add_cond_to_where');
     

    This should be added to Relevanssi documentation since I didn’t find anything.

    Still need answer for my extra questions!
    As per documentation I tried this code (https://www.relevanssi.com/knowledge-base/using-relevanssi-without-a-search-term/) to fallback to WordPress search in case search term is missing but meta_query is there and it results in zero posts returned (query with search term and meta query together works)

    • This reply was modified 5 years, 5 months ago by Anonymous User 17275278.
    • This reply was modified 5 years, 5 months ago by Anonymous User 17275278.

    I’m not allowed to do Relevanssi Premium support on these forums, please drop me a support request with the Relevanssi Premium support form.

    Thread Starter Anonymous User 17275278

    (@anonymized-17275278)

    I solved myself the issue about the premium feature, please consider adding the solution to the doc! I think it would help lots of users.
    Could you help with the other two minor issues that are non-premium feature so I don’t have to struggle with another request? Thank you

    Thread Starter Anonymous User 17275278

    (@anonymized-17275278)

    I will mark this as solved and open a new thread for the minor issues.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Relevanssi Premium] Custom fields in meta_query returning zero posts’ is closed to new replies.