列出具有来自分类法元字段的特定值的自定义术语

时间:2015-04-21 19:33:50

标签: php wordpress custom-taxonomy

我在完成这项工作时遇到了麻烦,但我确定答案就在那里。基本上,我想要的是按照他们的分类自定义元字段对我拥有的自定义分类法列表进行分组。我所拥有的是“名人”的自定义分类。我在该自定义分类法上添加了一个额外的元字段,并将其命名为“排序顺序”。现在我需要对所有名人进行分组'排序顺序值为' A',然后在另一列,B组中的名人组等等。

这是我的代码:

<ul>                
            <?php $args = array(
                    'taxonomy' => 'celebrity',
                    'meta_query' => array(
                            'key' => 'sort_order',
                            'compare' => '=',
                            'value' => 'A',
                             )              
                    ); ?>
            <?php $tax_menu_items = get_terms( $args );
            foreach ( $tax_menu_items as $tax_menu_item ):?>
            <li>
                <a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>">
                    <?php echo $tax_menu_item->name; ?>
                </a>
            </li>
            <?php endforeach; ?>
        </ul>

有些人可以帮助我理解我该如何实现这一目标?提前谢谢。

0 个答案:

没有答案
相关问题