Support

Account

Home Forums Front-end Issues True – false Reply To: True – false

  • @redeclipse

    get_page has been deprecated… it is recommended to use get_post() in favour of it.

    With that said… would a custom WP_Query be a better choice in this scenario?

    If you agree… check out an example below of the arguments that you could pass to the WP_Query when using a True/False ACF field.

    Hopefully you can pick apart and make sense of it for your use case:

    $projects_args = array(
      'post_type' => 'projects',
      'post_status' => 'publish',
      'relation' => 'AND',
      'meta_query' => array(
        array(
          'key' => 'cc_project_complete',
          'value' => FALSE,
          'compare' => '='
        ),
        array(
          'key' => 'cc_project_customer',
          'value' => $customer_id,
          'compare' => '='
        )
      ),
      'fields' => 'id, title, cc_project_job_num, cc_project_load_ship_date, cc_project_asap, cc_project_po_received_date, cc_project_dept_planned_1, cc_project_dept_planned_2, cc_project_dept_planned_3, cc_project_dept_planned_4, cc_project_dept_planned_5, cc_project_dept_planned_6, cc_project_dept_planned_7, cc_project_dept_planned_8, cc_project_dept_planned_9, cc_project_dept_planned_10, cc_project_dept_planned_11, cc_project_dept_planned_12, cc_project_dept_planned_13, cc_project_dept_planned_14, cc_project_dept_planned_15, cc_project_urgency, cc_project_asap_lead_time, cc_project_rush_lead_time, cc_project_standard_lead_time, cc_project_complete, cc_project_customer'
    );
    

    ‘cc_project_complete’ is my True/False ACF field. Also… you can decide what fields to return using ‘fields’. And in this example… I made sure that 2 criteria were satisfied by using ‘relation’ => ‘AND’ with my ‘meta_query’

    Hope that steers you in the right direction.