Support

Account

Home Forums Feedback Meta query with repeater field doc update

Solving

Meta query with repeater field doc update

  • Hey there,

    I’m working with meta_query to do a complex property search with repeater row search. Following the article here: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ (see sub custom fields section).

    I ran into a problem – the filter wasn’t being run. I tried adding suppress_filters => 0, but that resulted in a whole lot of crap I didn’t want (revisions, attachments, etc).

    I have found that you can do a similar filter but on the get_meta_sql filter instead of posts_where:

    function where_filter( $pieces ){
    	$pieces['where'] = str_replace("meta_key = 'stock_item_main_%", "meta_key LIKE 'stock_item_main_%", $pieces['where']);
    	return $pieces;
    }
    
    if($this->add_filter)
    	add_filter('get_meta_sql', 'where_filter');
    		
    $posts = get_posts($project_args);
    
    if($this->add_filter)
    	remove_filter( 'get_meta_sql', 'jalin_where_filter');

    Hope this helps someone.

  • Hi @mayte

    Could you please share the JSON or XML export of your field group and the PHP code you used?

    Thanks πŸ™‚

  • Sure thing;

    AJAX call with filter (line 101-106): http://pastebin.com/eQU6i1tZ
    JSON: http://pastebin.com/gDCUZPpX

  • Hi @mayte

    Thanks for sharing them. Could you please share the code at fault so I can try it on my end and see if I can come up with something? You can also try to provide the meta query manually to see if there’s something wrong with your meta query builder.

    But if you’re happy with your current code, I guess you can just leave it like that.

    Thanks πŸ™‚

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.