acf wordpress loop through and display blog posts order by date and type code example
Example 1: acf meta field query
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'color',
'value' => array('red', 'orange'),
'compare' => 'IN',
),
array(
'key' => 'featured',
'value' => '1',
'compare' => '=',
),
),
));
// args
$args = array(
'numberposts' => -1,
'post_type' => 'event',
'meta_key' => 'location',
'meta_value' => 'Melbourne'
);
// query
$the_query = new WP_Query( $args );
?>
have_posts() ): ?>
have_posts() ) : $the_query->the_post(); ?>
-
Example 2: acf wordpress loop through and display blog posts order by date and type
-1,
'post_type' => 'post'
));
if( $posts ): ?>