Site icon Hip-Hop Website Design and Development

How to create a meta_query to get all posts with a specific meta data?

Here are the args for my query :

$args = array(
        'post_type' => 'product',
        'posts_per_page' => -1,
        'meta_query' => array(
            array(
                'key' => 'vendor',
                'value' => 'farsi',
                'compare' => '=',
            ),
    )
    );

This doesn’t work when topics is a string, it gets me all products, But I need to get all products that have meta data (vendor) farsi.

UPDATE:

i use this code that move out of stock products to last product in archive:

add_action( 'pre_get_posts', 'move_out_of_stock_products_to_end' );

When stop it, the query work good.

So what can do !!