wordpress array in query code example
Example 1: wp query
have_posts() ) {
echo '';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '- ' . get_the_title() . '
';
}
echo '
';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Example 2: wp query meta in array
$args = array(
'post_type' => 'news',
'meta_query' => array(
array(
'key' => 'topics',
'value' => array ( 'sports', 'nonprofit', 'community' ),
'compare' => 'IN'
)
)
);