如何使用帖子类别的描述对其进行排序

时间:2019-09-27 作者:johnnitro

我正在尝试根据其描述对自定义帖子类别进行排序。我在下面试过了args 但它不起作用

$taxonomies = array(
    \'post_tag\',
    \'product-type\',
);

// Add the slugs of product types that should appear on the page
$slugs = array(
    \'hand-tools\',
    \'mechanical-tools\',
    \'abrasive-wheel\',
    \'garden-tools\',
    \'screens\',
    \'locks\'
);

$args = array(
    \'orderby\'           => \'description\',
    \'order\'             => \'DESC\',
    \'hide_empty\'        => false,
    \'exclude\'           => array(),
    \'exclude_tree\'      => array(),
    \'include\'           => array(),
    \'number\'            => $number,
    \'fields\'            => \'all\',
    \'slug\'              => $slugs,
    \'parent\'            => 0,
    \'hierarchical\'      => true,
    \'childless\'         => false,
    \'get\'               => \'\',
    \'name__like\'        => \'\',
    \'description__like\' => \'\',
    \'pad_counts\'        => false,
    \'offset\'            => $offset,
    \'search\'            => \'\',
    \'cache_domain\'      => \'core\'
);

1 个回复
SO网友:Dharmishtha Patel

我想您也可以添加自定义订单字段。

 $categories = get_categories( array(
        \'orderby\' => \'description\',
        \'order\'   => \'ASC\'
    ) );

相关推荐

如何将自定义选项添加到wp_Dropdown_Categories?

我需要将自定义选项添加到wp_dropdown_categories. 现在,整个万维网世界还没有找到解决方案。。。因此,我在这里要求一个解决方案……因为我真的无法想象WordPress的开发人员没有考虑到这将永远不需要,对吗?