我想知道如何在我在截图中圈出的选择字段中对自定义帖子的类别进行排序?
我有以下生成类别列表的代码
$args=array(
\'class\' => \'select-submit2\',
\'hide_empty\' => false,
\'selected\' => $prop_category_selected,
\'name\' => \'prop_category\',
\'id\' => \'prop_category_submit\',
\'orderby\' => \'NAME\',
\'order\' => \'ASC\',
\'show_option_none\' => __(\'None\',\'wpestate\'),
\'taxonomy\' => \'property_category\',
\'hierarchical\'=> true
);
wp_dropdown_categories( $args ); ?>
SO网友:David Lee
您需要更改orderby
到ID
:
$args=array(
\'class\' => \'select-submit2\',
\'hide_empty\' => false,
\'selected\' => $prop_category_selected,
\'name\' => \'prop_category\',
\'id\' => \'prop_category_submit\',
\'orderby\' => \'ID\', //this changed to ID
\'order\' => \'ASC\',
\'show_option_none\' => __(\'None\',\'wpestate\'),
\'taxonomy\' => \'property_category\',
\'hierarchical\'=> true
);
wp_dropdown_categories( $args ); ?>