【问题标题】:Wordpress show taxonomy with acfWordpress 使用 acf 显示分类
【发布时间】:2015-12-05 21:58:38
【问题描述】:

我无法在 WordPress 中使用 acf(选择多个)获取分类的名称。

$categories_user = get_field('product__services', $company_id);

当我var_dump($categories_user) 它输出:

array(2) { 
    [0]=> object(stdClass)#3816 (10) { 
        ["term_id"]=> int(28) 
        ["name"]=> string(17) "sous category 2-4" 
        ["slug"]=> string(17) "sous-category-2-4" 
        ["term_group"]=> int(0) 
        ["term_taxonomy_id"]=> int(28) 
        ["taxonomy"]=> string(11) "project_cat" 
        ["description"]=> string(0) "" 
        ["parent"]=> int(25) 
        ["count"]=> int(2) 
        ["filter"]=> string(3) "raw" 
    } 
    [1]=> object(stdClass)#3818 (10) { 
        ["term_id"]=> int(34) 
        ["name"]=> string(13) "Ywz categorie" 
        ["slug"]=> string(13) "ywz-categorie" 
        ["term_group"]=> int(0) 
        ["term_taxonomy_id"]=> int(34) 
        ["taxonomy"]=> string(11) "project_cat" 
        ["description"]=> string(0) "" 
        ["parent"]=> int(0) 
        ["count"]=> int(0) 
        ["filter"]=> string(3) "raw" 
    } 
} 

【问题讨论】:

  • 您能否详细解释一下您的问题,以便我们为您提供帮助?

标签: wordpress advanced-custom-fields


【解决方案1】:

您有数据...您只需要使用标准的foreach 循环显示它:

foreach ( $categories_user as $cat ) {
    echo $cat->name;
}

【讨论】:

    猜你喜欢
    • 2014-08-29
    • 2022-10-02
    • 1970-01-01
    • 2019-03-13
    • 2020-09-13
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    相关资源
    最近更新 更多