admin管理员组文章数量:1414908
I am trying to filter posts by a meta_query, based on a post field. The field type is checkbox.
The field configuration is:
acf_add_local_field_group(array (
'key' => 'group_5a579h8fs9a98a',
'title' => 'Bingo Options',
'fields' => array (
array (
'layout' => 'vertical',
'choices' => array (
'bingo' => 'This is Bingo promotion',
),
'default_value' => array (
),
'allow_custom' => 0,
'save_custom' => 0,
'toggle' => 0,
'return_format' => 'value',
'key' => 'field_59jafj0s5c9ea',
'name' => 'is_bingo_promotion',
'type' => 'checkbox',
'instructions' => 'Select this if you want this promotion to be shown on bingo page',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'promotions',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
So, inside the WP I get a checkbox. and when it is checked, i want this query to get it for me:
$args = array(
'post_type' => 'promotions',
'posts_per_page' =>-1,
'order' => 'DESC',
'meta_query' => array (
array (
'key' => 'is_bingo_promotion',
'value' => 'bingo',
'compare' => 'LIKE'
)
)
);
WP_Query( $args );
But this query doesn't filter the posts. It gets all of them. What am i doing wrong with the meta_query?
P.S. I know that the field type should have been true_false instead, but this is due to legacy.
本文标签: custom fieldFiltering posts by ACF meta query
版权声明:本文标题:custom field - Filtering posts by ACF meta query 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745189822a2646860.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论