【发布时间】:2018-01-21 06:08:34
【问题描述】:
我正在尝试根据我的 WordPress 网站中的高级自定义字段设置过滤器。基本上,我名为“ispremium”的高级自定义字段有两个值,即“是”和“否”,在下拉过滤器中,我将两个选项设置为“仅限高级”和“所有程序”。
I need to do when 'Premium Only' dropdown option is selected it will list all the post having value 'ispremium'='yes' and when all program is selected it will list both 'ispremium=yes' and 'ispremium= '不'。我有以下代码,但它总是列出带有“ispremium=yes”的帖子。我的代码有什么问题?
<select name="order" onchange="this.form.submit();">
<?php
$order_options = array(
'yes' => 'Premium Only',
'no' => 'All Programs',
);
$result = query_posts( array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'ispremium',
'value' => 'yes',
),
) ) );
$result = query_posts( array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'ispremium',
'value' => 'yes','no'
),
) ) );
foreach( $order_options as $result => $label ) {
echo "<option ".selected( $_GET['value'], $value )." value='$value'>$label</option>";
}
?>
</select>
【问题讨论】:
标签: wordpress filter advanced-custom-fields