如何获取我的注册分类

时间:2018-06-15 作者:rajasekar

我的分类法

    register_taxonomy(
        \'king_blog_category\', 
        \'king_blogs\',
         array(
            "hierarchical"          => true,
            "label"                 => "King blog Category",
            "singular_label"        => "label of taxonomy",
            \'update_count_callback\' => \'_update_post_term_count\',
            \'query_var\'             => true,
            \'rewrite\'               => array(
                \'slug\'              => \'king_blog_category\',
                \'with_front\'        => true
            ),
            \'public\'                => true,
            \'show_ui\'               => true,
            \'show_tagcloud\'         => true,
            \'_builtin\'              => true,
            \'show_in_nav_menus\'     => true
        )
    );
//获取方法//1:

$taxonomy = \'king_blog_category\';
$tax_terms = get_terms($taxonomy);
//2:

$taxonomy = \'king_blog_category\';
$tax_terms = get_terms($taxonomy, array(\'hide_empty\' => 0, \'parent\' =>0)); 
//结果:

array([invalid_taxonomy] => array([0] => Invalid taxonomy.))

1 个回复
SO网友:honk31

get_terms 第一个也是唯一一个参数应该是数组。docs

get_terms([
    \'taxonomy\' => \'king_blog_category\',
    \'hide_empty\' => 0,
    \'parent\' => 0
]);

结束

相关推荐

taxquery taxonomy get terms

我在编程和编码方面的知识非常有限。在我们的网站(旅行社)上,我们按地区(墨西哥、中美洲、南美洲和其他国家)提供不同的旅行样本,请参见:Neue Welt Reisen/trips当您选择行程时,例如。Costa Rica 您将在页面底部找到其他旅行示例。这些行程应选择来自同一地区,在这种情况下是美国中部,而不是其他三个地区。有一个脚本应该这样做,但结果只是来自墨西哥地区的旅行。因此,我的问题是:如何选择来自同一地区的示例旅行?代码如下:<div class="promo-trips-con