I've create a custom taxonomy for my products in woocommerce. It's the not hierarchical taxonomy of the authors of my bookstore. The code for the taxonomy is this:
add_action( 'init', 'create_autor_nonhierarchical_taxonomy', 0 );
function create_autor_nonhierarchical_taxonomy() {
// Labels part for the GUI
$labels = array(
'name' => _x( 'Autor', 'taxonomy general name' ),
'singular_name' => _x( 'Autor', 'taxonomy singular name' ),
'search_items' => __( 'Buscar autores' ),
'popular_items' => __( 'Autores populares' ),
'all_items' => __( 'Todos los autores' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Editar autor' ),
'update_item' => __( 'Actualizar autor' ),
'add_new_item' => __( 'Añadir nuevo autor' ),
'new_item_name' => __( 'Nombre del nuevo autor' ),
'separate_items_with_commas' => __( 'Separa los autores con comas' ),
'add_or_remove_items' => __( 'Añadir o eliminar autores' ),
'choose_from_most_used' => __( 'Elije ente los autores más utilizados' ),
'menu_name' => __( 'Autor' ),
);
// Now register the non-hierarchical taxonomy like tag
register_taxonomy('autor','product',array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'autor' ),
));
}
Well, everything works perfectly but now I'm not able to display the author. I'm trying using the following code but it doesn't work (it displays only the word "array"):
echo '<span>De '.get_the_terms($post->ID ,'autor').'</span>';
Anyone could help me?