Skip to content

Instantly share code, notes, and snippets.

@diegoliv
Last active December 3, 2015 13:39
Show Gist options
  • Save diegoliv/3b43c0e63c8fe77a31f5 to your computer and use it in GitHub Desktop.
Save diegoliv/3b43c0e63c8fe77a31f5 to your computer and use it in GitHub Desktop.
WP_Query com múltiplos meta_query
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$roi_min = (get_query_var('roi_min')) ? intval( get_query_var('roi_min') ) : false;
$roi_max = (get_query_var('roi_max')) ? intval( get_query_var('roi_max') ) : false;
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'paged' => $paged,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'roi_min',
'value' => $roi_min,
'compare' => '>=',
'type' => 'NUMERIC'
),
array(
'key' => 'roi_max',
'value' => $roi_max,
'compare' => '<=',
'type' => 'NUMERIC'
)
)
);
$reports = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment