I've add a custom taxonomy in my function.php. Here the code:
function create_autor_nonhierarchical_taxonomy() {
$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' ),
);
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' ),
));
}
add_action( 'init', 'create_autor_nonhierarchical_taxonomy', 0 );
function show_product_autor(){
$authors = wp_get_post_terms( get_the_ID(), 'autor' );
$author = array_pop($authors);
$authorTeamPg = get_page_by_title( $author->name, 'OBJECT', 'team' );
$authorTeamPgLink = get_permalink( $authorTeamPg->ID);
echo "<b>AUTOR: </b><a href='{$authorTeamPgLink}'>{$author->name}</a>",'<br />';
}
add_action( 'woocommerce_single_product_summary', 'show_product_autor', 24 );
Now, I've books that have more than 1 author. How could I change the code in order to display for instance 2 or 3 authors? Moreover there are books that have an editor, not properly an author (a books that have many authors and only one is in charge of the publication). Normally in this case the name of the editor is followed by a parenthesis like this (ed.). How could I add this option to the author field?