categories - How to sort post category using its Description

I Am trying to sort my custom post categories according to its description. I tried below args but it did not work$taxon

I Am trying to sort my custom post categories according to its description. I tried below args but it did not work

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

I Am trying to sort my custom post categories according to its description. I tried below args but it did not work

$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'
);
Share Improve this question edited Sep 27, 2019 at 7:05 Regolith 1981 gold badge3 silver badges12 bronze badges asked Sep 27, 2019 at 2:35 Krishneel SinghKrishneel Singh 101
Add a comment  | 

1 Answer 1

Reset to default 0

You can add custom order fields I suppose as well.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745125464a4612665.html

相关推荐

  • categories - How to sort post category using its Description

    I Am trying to sort my custom post categories according to its description. I tried below args but it did not work$taxon

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信