繁体   English   中英

如何设置自定义帖子类型术语和帖子的顺序

[英]how to set order of custom post type term and post's

您好,我正在使用自定义帖子类型显示计划。 我想自定义术语的顺序,这是我正在使用以下代码的

<?php
    $plan_group = get_terms('numbers_plans', array(
        'orderby' => 'description',  //this is for term order it's working
        'order'   => 'ASC'
    ));
    foreach ( $plan_group as $plan_group_term ) {
          $plan_group_query = new WP_Query( array(
                'post_type' => 'numbers_plan',
                'tax_query' => array(
                     array(
                          'taxonomy' => 'numbers_plans',
                          'field'    => 'slug',
                          'terms'    => array( $plan_group_term->slug )
                       )                                
                    )
                ));
 ?>

任何人都可以告诉我如何设置帖子的顺序。

嗨,我在代码下面完成了它,对我来说很有效!

<?php
    $plan_group = get_terms('numbers_plans', array(
        'orderby' => 'description',
        'order'   => 'ASC'
    ));
    foreach ( $plan_group as $plan_group_term ) {
        $plan_group_query = new WP_Query( array(
            'post_type' => 'numbers_plan',
            'meta_key'  => 'plan_minutes',
            'orderby'   => '0',
            'order'     => 'ASC',
            'tax_query' => array(
                array(
                    'taxonomy' => 'numbers_plans',
                    'field'    => 'slug',
                    'terms'    => array( $plan_group_term->slug )
                )
            )
        ));
    ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM