How to create dynamic value in WP_Query meta_query

You should be able to do what you’re trying to do. I think the issue may be that relation should not be contained in it’s own array. It should look like this:

$prodPost = new WP_Query( array(
    'post_type'         => 'product',
    'posts_per_page'    => 6,
    'paged'             => 1,
    'meta_query'        => array( array(
        'relation'  => 'AND',
        array(
            'key'       => 'product_last_date',
            'value'     => date('d-m-Y'),
            'compare'   => '>',
        ),
        array(
            'key'       => 'product_limit',
            'value'     => $limit,
            'compare'   => '>',
        ),
    ),
) );

If it’s still not working at that point I would verify your meta keys are the correct keys and $limit holds the expected value.


See Initializing Meta Query for more examples.