2014-12-23 3 views
0

방금 ​​WordPress 사이트의 다른 페이지에 '페이지 유형'을 추가하는 맞춤 분류를 만들었습니다. 페이지에 추가 할 수는 있지만 불행히도 이러한 분류를 CMS의 메뉴에 추가 할 수는 없습니다. 각 페이지는 '남성', '여성'또는 '정보'로 설정되므로 메뉴 항목으로 사용하는 것이 좋습니다. 아래에 코드를 제공했는데 도움이 될 것입니다. 감사!메뉴에 추가 할 때 맞춤법이 잘못되었습니다.

function add_custom_taxonomies() { 
    // Add new "Locations" taxonomy to Posts 
    register_taxonomy('Page-type', 'page', array(
    // Hierarchical taxonomy (like categories) 
    'hierarchical' => true, 
    // This array of options controls the labels displayed in the WordPress Admin UI 
    'labels' => array(
     'name' => _x('Page Types', 'taxonomy general name'), 
     'singular_name' => _x('Page Type', 'taxonomy singular name'), 
     'search_items' => __('Search page types'), 
     'all_items' => __('All page types'), 
     'parent_item' => __('Parent page type'), 
     'parent_item_colon' => __('Parent page type:'), 
     'edit_item' => __('Edit page type'), 
     'update_item' => __('Update page type'), 
     'add_new_item' => __('Add new page type'), 
     'new_item_name' => __('New page type Name'), 
     'menu_name' => __('Page Types'), 
    ), 
    // Control the slugs used for this taxonomy 
    'rewrite' => array(
     'slug' => 'page-types', // This controls the base slug that will display before each term 
     'with_front' => false, // Don't display the category base before "/locations/" 
     'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/" 
    ), 
)); 
} 
add_action('init', 'add_custom_taxonomies', 0); 

답변

0

인해 데이터베이스 구조 제한에 대한 분류의 이름은 (Codex)를 소문자와 밑줄을 포함하고 있으며 32 명 이상의 자이어야한다.

+0

감사합니다! 이 부분을 살펴보고 필요한 부분을 업데이트하고 다시 방문하겠습니다! – Chuck

0

분류 이름은 소문자 여야합니다. 그렇지 않으면 메뉴에 표시되지 않으며 'show_in_nav_menus'도 true이어야합니다.

관련 문제