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

时间:2017-05-18 10:28:53

标签: wordpress

大家好我正在使用自定义帖子类型来展示计划。我想自定义术语的顺序,以及我在下面使用代码

的帖子
<?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 )
                       )                                
                    )
                ));
 ?>

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

1 个答案:

答案 0 :(得分:0)

嘿,伙计们我已经在代码下面完成了它为我工作!!

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