我正在编写一个 shorcode API 函数。我想从 中保存选定的值wp_dropdown_categories
以在wp_query
.
echo `<form action="" method="POST">`;
$values = array(
`orderby` => `name`,
`order` => `ASC`,
`echo` => 1,
`selected` => $kat = get_query_var( `cat` ),
`name` => 'cat',
`id` => ``,
`taxonomy` => `persons`
);
wp_dropdown_categories( $values );
echo `<input type="submit" name="submit" value="view" />;
echo `</form>`;
我想使用选定的值在自定义分类中进行搜索
$args = array(
`post_type` => `client`,
`persons` => `here selected value from wp_dropdown_categories`
);
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ) {
echo `Name: `;
while ($my_query->have_posts()) : $my_query->the_post();
echo the_title();
endwhile;
}