gpt4 book ai didi

php - 如何通过按特定顺序使用 ID 来获取分类术语

转载 作者:行者123 更新时间:2023-12-02 17:41:02 26 4
gpt4 key购买 nike

我正在尝试通过使用他们的 ID 来获取我的分类术语,但我想按特定顺序而不只是 ASC 来订购我的 ID

$taxonomy = 'menu-food-categories';
$taxonomy_terms = get_terms( $taxonomy, 'orderby=ID&order=ASC&parent=0' );

类似于:

$args_terms = array(
'post_in' => array(49,5,12,80),
'orderby' => post_in,
'parent' => '0'
);

$taxonomy = 'menu-food-categories';
$taxonomy_terms = get_terms($taxonomy, $args_terms);

最佳答案

你可以这样做

// Get term by id (''term_id'') in Categories taxonomy.
get_term_by('id', 12, 'category')

as per this link

通过下面的代码获取更多信息::

$taxonomy = 'menu-food-categories';
$args_terms_id_list = array(49,5,12,80);

foreach ($args_terms_id_list as $current_term_id){
// Get term by id (''term_id'') in Categories taxonomy.
$taxonomy_terms = get_term_by('id', $current_term_id , $taxonomy)
// Do your code here
}

谢谢

关于php - 如何通过按特定顺序使用 ID 来获取分类术语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20673220/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com