如何在子类别中对wordpress类别进行排序?

时间:2018-11-01 21:29:40

标签: wordpress custom-wordpress-pages

在我的wordpress网站上,我想列出按年份订购的艺术品。我目前的策略是每年有一个父类别“作品”和一个子类别“ 2017”,“ 2018”,依此类推。我可以获取父类别,但是我如何按子类别对作品进行排序(年份)?

这是我现在拥有的:

function custom_category_loop() {
// Grab all the categories from the database that have posts.
$categories = get_terms( 'category', 'orderby=name&order=ASC');

// Loop through categories
foreach ( $categories as $category ) {

    //categories Works and Exhibitions should be displayed only, and posts sorted by year
    if ($category->term_id == 4 or $category->term_id == 5) {

非常感谢您的帮助! (我的头需要刷新:-))

弗雷德

0 个答案:

没有答案