Home › Forums › Front-end Issues › How to output posts from different CPTs that have a specific ACF field set? › Reply To: How to output posts from different CPTs that have a specific ACF field set?
Do all of these post types have a unique ACF field name (meta_key) that exists for these post types but does not exist for the other post types that you do not want to show?
if the answer is yes
$args = array(
'post_type' => 'any',
'meta_query' =>
array(
'key' => 'field_name',
'compare' => 'EXISTS'
)
)
);
$my_query = new WP_Query($args);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.