Answers for "get acf field from custom post type using wp_query"

PHP
0

acf wp_query custom field

// WPQuery using ACF basic fields
$args = array( 
	'post_type'   => 'post',
    'posts_per_page' => '20',
    'meta_key'		=> 'color',
    'meta_value'	=> 'blue' // Can be string or true/false
);
$posts = new WP_Query( $args );
Posted by: Guest on December-30-2021
0

wp_query custom post type filter by acf field value

<?php 

$posts = get_posts(array(
	'posts_per_page'	=> -1,
	'post_type'			=> 'post'
));

if( $posts ): ?>
	
	<ul>
		
	<?php foreach( $posts as $post ): 
		
		setup_postdata( $post );
		
		?>
		<li>
			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
		</li>
	
	<?php endforeach; ?>
	
	</ul>
	
	<?php wp_reset_postdata(); ?>

<?php endif; ?>
Posted by: Guest on November-23-2020

Code answers related to "get acf field from custom post type using wp_query"

Browse Popular Code Answers by Language