gpt4 book ai didi

php - get_terms WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy. ) ) [error_data] => Array ( ) )

转载 作者:行者123 更新时间:2023-12-05 08:41:12 25 4
gpt4 key购买 nike

<分区>

如何解决 get_terms 函数的 WP_Error 对象?我在 coustom-post-type.php 文件中注册了自定义分类法 tax_alone_event。并包含在 functions.php 文件中。这是我的代码

function get__terms_list() {
$terms = get_terms('tax_alone_event');
return $terms ;

} //End get_terms_list()..

print_r(get__terms_list());

我在 coustom-post-type.php 文件中注册了自定义帖子和自定义分类代码

function Alone_setup_post_type_project() {
// event custom post and tax
$alone_event_args = array(
'labels' => array(
'name' => _x( 'Event', 'post type general name', 'alonefoundation' ),
'add_new' => _x( 'Add New', 'Event', 'alonefoundation' ),
'add_new_item' => __( 'Add New Event', 'alonefoundation' ),
'new_item' => __( 'New Event', 'alonefoundation' ),
'edit_item' => __( 'Edit Event', 'alonefoundation' ),
'view_item' => __( 'View Event', 'alonefoundation' ),
'all_items' => __( 'All Event', 'alonefoundation' ),
),
'description' => __( 'Description.', 'alonefoundation' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'event' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'taxonomies' => array('tax_alone_event'),
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail')
);
register_post_type( 'alone-event', $alone_event_args );
$alone_event_tax = array(
'label' => __( 'Category' ),
'rewrite' => array( 'slug' => 'event_tax' ),
'hierarchical' => true,
) ;
register_taxonomy( 'tax_alone_event', array('alone-event'), $alone_event_tax );
}

add_action( 'init', 'Alone_setup_post_type_project');

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