我改变了我的功能。php文件添加了一个名为“autor”的新分类法。代码如下:
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\' ),
));
}
add_action( \'woocommerce_single_product_summary\', \'show_product_autor\', 24 );
function show_product_autor(){
the_terms( $post->ID, \'autor\', \'<b>AUTOR: </b>\', \', \', \'<br />\' );
}
一切都很完美,但我希望出现在作者名字中的链接将重定向到作者页面(团队插件),而不是商店页面。如何编辑代码以将分类法链接到团队页面?例如,在此页面中https://www.editorialufv.es/catalogo/territory-inhabited/ 如果单击作者Elena Farini的名字,您将被重定向到他的书(在本例中只有一本),而不是他的团队页面:https://www.editorialufv.es/team/elena-farini/