Home › Forums › Front-end Issues › True – false › Reply To: True – false
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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN
— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.
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.