Support

Account

Home Forums Front-end Issues How to output posts from different CPTs that have a specific ACF field set?

Helping

How to output posts from different CPTs that have a specific ACF field set?

  • Hello,
    I’m building a news portal where I have few different CPTs (news types). Each CPT has the same ACF field set. I’d like to show an archive of articles coming from all CPTs that have a specific ACF field set. Any hints? Thx.

  • 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);
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.