我有一个循环,我有一些标准的排序选项,包括排序日期&标题。我还有一个第三个选项,我希望添加哪个过滤掉" Studio"质量帖子...我添加了一个复选框,我可以在后端为每个帖子选择或取消选择但是如何将其添加到我的过滤器中?
我编写了这段代码,允许最终用户对帖子进行排序,但我需要添加第3个选项
<div class="btn-group btn-group-vi">
<button type="button" class="btn btn-sort dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php if(!empty($orderby == 'title')) { echo "Alphabetical"; } elseif($orderby = 'date') { echo "Date Added"; } else { echo "Order by"; } ?></button>
<div class="dropdown-menu">
<a class="dropdown-item" href="?orderby=title<?php if(!empty($order)) { echo "&order=" . $order; } ?>">Alphabetical</a>
<a class="dropdown-item" href="?orderby=date<?php if(!empty($order)) { echo "&order=" . $order; } ?>">Date Added</a>
</div>
</div>
<div class="btn-group btn-group-vi">
<button type="button" class="btn btn-sort dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php if(!empty($order == 'asc')) { echo "ASC"; } elseif($order = 'desc') { echo "DESC"; } else { echo "Order"; } ?></button>
<div class="dropdown-menu">
<a class="dropdown-item" href="<?php if(!empty($orderby)) { echo "?orderby=" . $orderby . "&"; } ?>order=asc">ASC</a>
<a class="dropdown-item" href="<?php if(!empty($orderby)) { echo "?orderby=" . $orderby . "&"; } ?>order=desc">DESC</a>
</div>
</div>
<?php
$loop = new WP_Query( array(
'post_type' => 'acapella',
'posts_per_page' => 18,
'paged' => $paged,
'orderby' => $orderby,
'order' => $order
));
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
?>
答案 0 :(得分:0)
编辑你的args,包括元键&#34; studio_acapella&#34;:
$loop = new WP_Query( array(
'post_type' => 'acapella',
'posts_per_page' => 18,
'paged' => $paged,
'orderby' => $orderby,
'order' => $order,
'meta_query' => array(
array(
'key' => 'studio_acapella',
'value' => true
),
)
)
));