如何根据主题的unction.php中的id对定制帖子的类别进行排序?

时间:2017-02-11 作者:anandmongol

我想知道如何在我在截图中圈出的选择字段中对自定义帖子的类别进行排序?

my idea is to sort custom post's categories in the selection field which encircled

我有以下生成类别列表的代码

 $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 ); ?>

1 个回复
SO网友:David Lee

您需要更改orderbyID:

            $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 ); ?>

相关推荐

WooCommerce:如何在Order元数据对象中获得具有自定义ID的订单?

因为一个项目,我需要你的帮助。我找了很多,但找不到解决办法。我正在尝试编辑一个名为woocommerce\\u account\\u订单我已经添加了该字段mycustom\\u id到订单元数据对象,因为我需要在字段mycustom\\u id中获取当前登录用户的所有订单:(mycustom\\u id=current\\u user\\u id())检查customer 应该留下来。我只需要再加上这个current_user_id 检查这应该保持原样:\'客户\'=>获取当前用户id()。这是我的