Support

Account

Forum Replies Created

  • Thanks Elliot. I’ve been getting various answers on this across various forums, but nothing’s working unfortunately. Here are 2 things that I tried, per suggestions –

    $args = array( 'post_type' => 'project', 'meta_query' => array('key' => 'homepage_slide', 'compare' => 'EXISTS'));

    and

    $args = array( 'post_type' => 'project', 'meta_query' => array('key' => 'homepage_slide', 'value' => 'true' , 'compare' => 'LIKE'));

    It’s been awhile since I’ve been stumped by what started as a simple concept! I may not be thinking about this clearly…

  • I don’t think you have yet explained what type of field is ‘homepage_slide’.

    The type of field is just an Image and I’m including it as a direct path to the image, per example –

    <img src="<?php the_field('homepage_slide'); ?>" alt="slide" />

    Is there a better way to do this?

  • It’s odd, but this still doesn’t work –

    $args = array( 'post_type' => 'project', 'meta_query' => array('key' => 'homepage_slide', 'value' => '1'));

    I will check out a debug plugin and see if I see anything wrong.

    Just curious, if you were trying to do the same thing (add slides to a slideshow only if the homepage_slide field was completed), how would you write the query?

  • Unfortunately when I change it, it still loops through all projects and displays a broken image, rather than only catching projects with slideshow images:

    $args = array( 'post_type' => 'project', 'meta_query' => array('meta_key' => 'homepage_slide','meta_value' => 'true'));

  • Hmm, looks like meta_key worked, rather than key…

  • Thanks Elliot. I changed to lowercase, but it’s still displaying all projects, instead of filtering for construction. Any ideas for writing the query differently?

Viewing 6 posts - 1 through 6 (of 6 total)