Support

Account

Home Forums ACF PRO Post Object modify filter Reply To: Post Object modify filter

  • Update

    I managed to make it filter based on 2 custom fields, but it is not searching by title now

    function filter_products_by_sku( $args, $field, $post_id ) {
        $the_search = $args['s'];
        unset($args['s']);
    	$args['meta_query'] = array(
    		'relation'		=> 'OR',
    	    array(
    		    'key' => 'sku_number',
    		    'value' => $the_search,
    		    'compare' => 'LIKE',
    		),
    		array(
    			'key'	  	=> 'old_id',
    			'value'	  	=> $the_search,
    			'compare' 	=> 'LIKE',
    		)
    	); 
        return $args;
    }
    add_filter('acf/fields/post_object/query/key=field_5f58a23b95d62', 'filter_products_by_sku', 10, 3);