Support

Account

Home Forums General Issues Filter and display CPT based on file ACF value

Helping

Filter and display CPT based on file ACF value

  • Hi, I’m looking to display a list of posts based on whether they have a file uploaded to them or not

    The code I have so far is:

    `
    $args = array(
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘job_status’,
    ‘field’ => ‘slug’,
    ‘terms’ => array( ‘complete’ )
    ),
    ),
    ‘post_type’ => ‘jobs’
    );
    $loop = new WP_Query($args);
    if($loop->have_posts()) {
    $term = $wp_query->queried_object;
    while($loop->have_posts()) : $loop->the_post();
    //Output what you want
    echo ‘<li><a href=”‘.get_permalink().'”>’.get_the_title().'</a></li>’;
    endwhile;
    }
    `

    I’m guessing I need a second array where the
    post type = jobs,
    field = name of the ACF file field
    but I’m not sure how to do the ‘has a value/hasn’t got a value’ part

    Thanks in advance

Viewing 1 post (of 1 total)

The topic ‘Filter and display CPT based on file ACF value’ is closed to new replies.