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


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(
    ‘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>’;

    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)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.