我有一个带有 2 个单选按钮的表单 - 根据用户选择的内容,我想更改一个变量以将排序顺序从日期更改为标题:
<form action="<?php echo home_url( '/' ); ?>" method="get" id="searchform2">
<input type="radio" name="sort" value="date" checked> Order by date
<input type="radio" name="sort" value="title"> Order by title
<input type="submit" id="searchsubmit2" class="search-submit" value="Search" />
</form>
<?php if(isset($_GET['sort']) == "date") {
$sort = ($_GET['sort']);
$order = "DESC";
} else {
$sort = ($_GET['sort']);
$order = "ASC";
}
$args = array(
'post_type' => 'policies',
'orderby' => $sort,
'order' => $order
);
?>
目前,排序变量根据选择输出正确的内容,但顺序不是。无论选择什么,它都会输出“DESC”。我哪里错了?