I've read all the posts about displaying terms of a custom taxonomy and it's still not working. Ok, so here's the code:
<?php
//part of template-offer.php
$taxonomy = 'brand';
$term_args=array(
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC'
);
$tax_terms = get_terms($taxonomy,$term_args);
echo $tax_terms;
?>
And on the output I'm only getting an empty array. I'm staring at the code and can't find out why. I have both my custom post and taxonomy working, created some posts and terms:
<?php
//creating a custom taxonomy called 'brand'
add_action( 'init', 'create_custom_taxonomies', 0 );
function create_custom_taxonomies() {
$labels = array(
'name' => _x( 'Brands', 'taxonomy general name' ),
'singular_name' => _x( 'Brand', 'taxonomy singular name' ),
'search_items' => __( 'Search Brands' ),
'all_items' => __( 'All Brands' ),
'parent_item' => __( 'Parent Brand' ),
'parent_item_colon' => __( 'Parent Brand:' ),
'edit_item' => __( 'Edit Brand' ),
'update_item' => __( 'Update Brand' ),
'add_new_item' => __( 'Add New Brand' ),
'new_item_name' => __( 'New Brand Name' ),
'menu_name' => __( 'Brand' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'brand' ),
);
register_taxonomy( 'brand', null , $args );
}
//creating a custom post type that is using 'brand' taxonomy
function create_post_type() {
register_post_type( 'products',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' ),
'add_new' => _x('Add New', 'products'),
'add_new_item' => __('Add New Product'),
'edit_item' => __('Edyt Product'),
'new_item' => __('New Product'),
'view_item' => __('View Product'),
'search_items' => __('Search Product'),
'not_found' => __('Nothing found'),
),
'taxonomies' => array('brand'),
'supports' => array('title', 'editor', 'thumbnail'),
'public' => true,
'has_archive' => true,
'show_ui' => true,
)
);
}
add_action( 'init', 'create_post_type' );
?>
Your help will be highly appreciated. Have a nice day, Patryk