这是我的查询设置
$recipe_args = array(
\'post_type\' => \'recipes\',
\'post_status\' => \'publish\',
\'posts_per_page\' => $per_page,
\'author\' => $author->ID,
\'paged\' => $paged,
);
$recipes = new WP_Query( $recipe_args );
使用此下拉框,我想更改查询结果
<select name="orderby" class="orderby">
<option value="menu_order">Default sorting</option>
<option value="popularity">Sort by popularity</option>
<option value="rating">Sort by average rating</option>
<option value="date">Sort by newness</option>
<option value="price">Sort by price: low to high</option>
<option value="price-desc">Sort by price: high to low</option>
</select>
url结构为/作者姓名/?页面=配方(使用
add_query_arg()
功能)
我接下来应该做什么,以便在选择下拉选项时加载新页面,例如/作者姓名/?页码=配方(&P);orderby=将以下代码添加到主WP\\U查询的流行程度。
$recipe_args[\'order\'] = \'DESC\';
$recipe_args[\'orderby\'] = \'meta_value_num\';
$recipe_args[\'meta_query\'][] = array(
\'key\' => \'km_receipes_sales\',
\'compare\' => \'>=\',
\'value\' => \'0.01\',
);
非常感谢您的帮助。