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 );

?>
<?php if( $the_query->have_posts() ): ?>
	<ul>
	<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
		<li>
			<a href="<?php the_permalink(); ?>">
				<img src="<?php the_field('event_thumbnail'); ?>" />
				<?php the_title(); ?>
			</a>
		</li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

<?php wp_reset_query();	 // Restore global post data stomped by the_post(). ?>

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
acf meta query false meta query on acf acf field meta key query acf meta_query option page acf meta query number field meta query by acf field meta query in texonomy acf field acf meta query acf field acf meta query on int field acf field in meta query acf meta_query false field acf field as metadata acf with meta query query acf field in user meta acf wordpress query filter Filter by Post Type field in acf meta query advanced custom fields advanced custom fields wordpress search query pre_get_posts query-&gt;set search custom fields pre get post qp query archive selection wp_query with acf field wordpress get posts acf meta field have_posts get acf custom post search with acf field wp meta_query acf field get post by custom field query posts by acf gallery field get cpt by acf field acf meta query wp_query acf field acf query posts by id acf query posts array acf query posts acf meta query number get posts return custom field how to post inside custom field get data in user add section acf add variable to wp query get_posts custom field wordpress filter posts by custom field wordpress filter posts by acf field acf wp query with acf field acf get post by custom field acf filter custom field how to get post type's custom field in acf query acf acf get field guery from the post type acf query post by custom field acf query field between acf query field acf get all posts with field acf wp query acf wordpress loop through and display blog posts order by date and type acf meta_query compare IN wp query get post by with acf field how to display acf field from post type query meta_query wordpress acf get post by acf field wp query acf meta key get custom post type posts with acf getpost with acf wordpress acf insert field query acf custom fields meta_key how to query in wordpress based on an acf field how to query post basedo n acf field wordpress query custom post type with acf field query posts by acf field value get post ACF acf meta field query in acf meta field query
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source