I have the following code but it is only returning the latest 6 post instead of the conditions in the meta query. What am I doing wrong that it is ignoring the meta_query?
I have tried different conditions as well and still only the latest 6 posts are returned.
$Args = array( 'post_type' => 'equipment',
'posts_per_page' => 6,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'price',
'value' => 5000,
'compare' => '<='
)
)
);
$Query = new WP_Query( $Args );
if($Query->have_posts())
{
$HTML = '<div class="row">';
foreach($Query->posts as $Post)
{
$Meta = get_post_meta($Post->ID);
$Image = get_the_post_thumbnail($Post->ID,'thumbnail');
$HTML .= '<div class="col-md-4">
<a href="" title="">'.$Image.'</a>
<div class="product-info">
<h3 class="" style="margin-bottom:15px">
<a style="color:#ff750c !important" href="" title="'.$Post->post_title.'">
'.$Post->post_title.'</a>
</h3>
<div>
<strong class="yellow-text">Regular Price: $'.number_format($Meta['price'][0],2).'</strong>
</div>
<div style="color:#ff750c;"><strong>Sale Price: $'.number_format($Meta['sale_price'][0],2).'</strong></div>
</div>
</div>';
}
$HTML .= '</div>';
}