2017-12-18 38 views
1

woocommerce에서 내 제품에 대한 사용자 지정 분류 체계를 만들었습니다. 서점의 저자에 대한 계층 적 분류가 아닙니다.제품의 사용자 지정 분류 표시

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'), 
)); 
} 

글쎄, 모든 것이 완벽하게 작동하지만 지금은 저자를 표시 할 수 아니에요 : 분류 체계에 대한 코드는 이것이다. 다음 코드를 사용하려고하지만 작동하지 않습니다. 단어 "배열"만 표시됩니다.

echo '<span>De '.get_the_terms($post->ID ,'autor').'</span>'; 

누구든지 나를 도울 수 있습니까? 이 솔루션은 대신 get_the_term_list() 기능을 사용

+0

: (((나는 내가 WC_Post_types을 확인했습니다 잃었어요하지만 난 찾고 있어요 코드를 발견하지 않았습니다 – Stefano

+0

오, 그래.. !!! 솔루션을 찾으십시오 : De '.get_the_term_list ($ post-> ID,'autor ').' ' – Stefano

답변

1

:

echo '<span>De ' . get_the_term_list($post->ID, 'autor') . '</span>'