I’m trying to write a WP_Query which uses some data from two ACF checkboxes as part of the arguments.
I found the documentation showing how to use fields in custom queries however I cannot work out what the correct syntax for my checkboxes is.
My ACF’s:
- Label: Promote to homepage?
- Name: promote_to_homepage
- Choices: Promoteto homepage : Promote to homepage
- Label: Make feature?
- Name: make_feature
- Choices: Show as feature : Show as feature (top of homepage)
This is the query I have:
$the_query = new WP_Query(
array
(
'posts_per_page' => 1,
'meta_key' => 'promote_to_homepage',
'meta_value' => 'Promote to homepage',
'meta_key' => 'make_feature',
'meta_value' => 'Make feature'
)
);
I guess what I can’t figure out is why data is actually needed for meta_key and meta_value. Is the key the label? Is the value one of the choices? Or do I need to use meta_value => true or something? I have tried many variations and cannot get it to work.
Essentially what I want to do is output the most recent post that is ticked true/yes for “Promote to homepage” and “Make feature”.
I have also tried:
array
(
'posts_per_page' => 1,
'meta_key' => 'promote_to_homepage',
'meta_value' => true,
'meta_key' => 'make_feature',
'meta_value' => true
)
Aucun commentaire:
Enregistrer un commentaire