从数组中删除未分类的WP_Term对象

时间:2019-06-03 08:16:42

标签: php multidimensional-array woocommerce

我想从WP_Term对象数组中删除“未分类”。 我不想使用functions.php来做。这是我的自定义代码,用于显示woocommerce产品的类别。

这是数组原始输出:

Array
(
    [0] => WP_Term Object
        (
            [term_id] => 18
            [name] => Antique Furniture
            [slug] => antique-furniture
            [term_group] => 0
            [term_taxonomy_id] => 18
            [taxonomy] => product_cat
            [description] => 
            [parent] => 0
            [count] => 1
            [filter] => raw
        )

    [1] => WP_Term Object
        (
            [term_id] => 17
            [name] => Antique Jewellery
            [slug] => antique-jewellery
            [term_group] => 0
            [term_taxonomy_id] => 17
            [taxonomy] => product_cat
            [description] => 
            [parent] => 0
            [count] => 1
            [filter] => raw
        )

    [2] => WP_Term Object
        (
            [term_id] => 19
            [name] => Antique Porcelain
            [slug] => antique-porcelain
            [term_group] => 0
            [term_taxonomy_id] => 19
            [taxonomy] => product_cat
            [description] => 
            [parent] => 0
            [count] => 1
            [filter] => raw
        )

    [3] => WP_Term Object
        (
            [term_id] => 16
            [name] => Antique Silver
            [slug] => antique-silver
            [term_group] => 0
            [term_taxonomy_id] => 16
            [taxonomy] => product_cat
            [description] => 
            [parent] => 0
            [count] => 1
            [filter] => raw
        )

    [4] => WP_Term Object
        (
            [term_id] => 15
            [name] => Uncategorized
            [slug] => uncategorized
            [term_group] => 0
            [term_taxonomy_id] => 15
            [taxonomy] => product_cat
            [description] => 
            [parent] => 0
            [count] => 0
            [filter] => raw
        )

)

请帮助我获取此代码。

提前谢谢。

0 个答案:

没有答案