admin管理员组文章数量:1313752
I have to sort my results by number:
<ul>
<?php $productTerms = get_terms('prezzoceste', array('hide_empty' => 0, 'orderby' => 'ASC', 'meta_type' => 'NUMERIC', ));
foreach($productTerms as $productTerm) :
?>
<li>
<i class="fas fa-circle"></i>
<a href="<?php echo get_term_link( $productTerm->slug, $productTerm->taxonomy ); ?>"><?php echo $productTerm->name; ?> <span>(<?php echo $productTerm->count; ?>)</span></a>
</li>
<?php endforeach; ?>
</ul>
I have to sort my results by number:
<ul>
<?php $productTerms = get_terms('prezzoceste', array('hide_empty' => 0, 'orderby' => 'ASC', 'meta_type' => 'NUMERIC', ));
foreach($productTerms as $productTerm) :
?>
<li>
<i class="fas fa-circle"></i>
<a href="<?php echo get_term_link( $productTerm->slug, $productTerm->taxonomy ); ?>"><?php echo $productTerm->name; ?> <span>(<?php echo $productTerm->count; ?>)</span></a>
</li>
<?php endforeach; ?>
</ul>
Share
Improve this question
asked Nov 28, 2020 at 2:25
AndreaLBAndreaLB
174 bronze badges
1 Answer
Reset to default 1You are using pre 4.5.0 code which will eventually be depricated. Try this.
$productTerms = get_terms( array(
'taxonomy' => 'prezzoceste',
'hide_empty' => false,
'orderby' => 'ASC',
'meta_key' => '_price', //The price Meta Key
'orderby' => 'meta_value_num',
) );
Check this for more accepted arguments.
本文标签: How to sort by number
版权声明:本文标题:How to sort by number 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741956958a2407043.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论