我有一个自定义帖子类型“fee”,它有一个自定义分类“fee category”。
我正在尝试按名称查找分类法中项目的ID。我应该不能使用get_term_by()
?
比如:get_term_by(\'name\', \'Sample Name\', \'fee-category\')
我甚至试着用ID来寻找分类法,使用我知道存在且没有运气的ID。
有人知道我应该使用哪个函数吗?
也许我的代码中有注册分类法的内容?这是:
add_action( \'init\', \'create_fee_taxonomy\' );
function create_fee_taxonomy() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
\'name\' => _x( \'Fee Category\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Fee Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Fee Categories\' ),
\'all_items\' => __( \'All Fee Categories\' ),
\'parent_item\' => __( \'Parent Fee Category\' ),
\'parent_item_colon\' => __( \'Parent Fee Category:\' ),
\'edit_item\' => __( \'Edit Fee Category\' ),
\'update_item\' => __( \'Update Fee Category\' ),
\'add_new_item\' => __( \'Add New Fee Category\' ),
\'new_item_name\' => __( \'New Fee Category Name\' ),
\'menu_name\' => __( \'Fee Category\' ),
);
register_taxonomy( \'fee-category\', array( \'fee\' ), array(
\'public\' => true,
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
) );
}