How filter by ACF Flexible Content in WordPress?

  Kiến thức lập trình

I use WordPress and ACF plugin.

I create field type “Flexible Content” with code “variants”
In “Flexible Content” i create field type “Number” with code “price”

One product may have several price options. I want to receive all products with at least one price greater than 1000

Example:

Product 1

Flexible Content:

    - price: 1000
    - price: 2000
    - price: 3000
$args = [
    [post_type] => products
    [meta_query] => Array
        (
            [relation] => AND
            [0] => Array
                (
                    [0] => Array
                        (
                            [key] => variants
                            [value] => price
                            [compare] => LIKE
                        )

                    [1] => Array
                        (
                            [key] => price
                            [value] => 1000
                            [compare] => >
                            [type] => NUMERIC
                        )

                )

        )
    [posts_per_page] => 20
    [paged] => 1
]

new WP_Query( $args );

This code does not return anything, is it possible to somehow implement similar functionality?

LEAVE A COMMENT