Support

Account

Home Forums Backend Issues (wp-admin) Loop through posts if True/False Reply To: Loop through posts if True/False

  • Hi,
    If you want to show only the posts that have a true/false checkbox checked (the checkbox that trigger the two other field on your backend).
    you should restrict to these posts directly on your query

    'meta_query' => array(
        'post_type' => 'areas-of-focus',
        array(
         'key' => 'is_a_featured_area_of_focus',
         'value' => '1',
         'compare' => '=='
        )
     )

    something like that should return only the posts that have the is_a_featured_area_of_focus field set to true.

    so you can get rid of if( get_field('is_a_featured_area_of_focus') ) : and other stuff related to checking if this field is checked on the loop and just take care of the layout.

    let me know how that goes