2017-11-08 8 views
0

나는 워드 프레스에서 맞춤 카테고리 분류를 작성했습니다. 그리고 성공적으로 만들고 wordpress admin에 표시합니다.알 수없는 오류가 발생했습니다. 사용자 정의 분류/카테고리

문제 :

  1. 나는 새로운 카테고리를 추가하려고하지만 새로 만든 범주를 보여 먼저 페이지를 새로 고침 할 필요가있다.

  2. 카테고리를 삭제하면 해당 카테고리가 An unidentified error has occurred이고 목록은 여전히 ​​목록에 있습니다. 카테고리가 삭제되도록 페이지를 새로 고침해야합니다.

여기 내 코드

// hook into the init action and call create_schedule_taxonomies when it fires 
add_action('init', 'create_schedule_taxonomies', 0); 

// create two taxonomies, genres and writers for the post type "book" 
function create_schedule_taxonomies() { 
    // Add new taxonomy, make it hierarchical (like categories) 
    $labels = array(
     'name'    => _x('Categories', 'taxonomy general name'), 
     'singular_name'  => _x('Category', 'taxonomy singular name'), 
     'search_items'  => __('Search Category'), 
     'all_items'   => __('All Categories'), 
     'parent_item'  => __('Parent Category'), 
     'parent_item_colon' => __('Parent Category:'), 
     'edit_item'   => __('Edit Category'), 
     'update_item'  => __('Update Category'), 
     'add_new_item'  => __('Add New Category'), 
     'new_item_name'  => __('New Category'), 
     'menu_name'   => __('Categories'), 
     // more labels here... 
    ); 

    $args = array(
     'hierarchical'  => true, 
     'labels'   => $labels, 
     'show_ui'   => true, 
     'show_in_rest'  => true, 
     'show_admin_column' => true, 
     'query_var'   => true, 
     'rewrite'   => array('slug' => 'schedule_category'), 
    ); 
    register_taxonomy('schedule_category', array('schedule'), $args); 
} 

의 우리가 어떻게 해결할 수 있습니까?

+0

자바 스크립트 오류가있는 경우 브라우저 콘솔을 확인하십시오 –

+0

콘솔 오류가 없습니다 – JSmith

+0

열린 콘솔에서 오류 스크린 샷을 공유 할 수 있습니까? –

답변

0
function create_schedule_taxonomies() { 
register_taxonomy( 
    'schedule_category', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). 
    'schedule' ,  //post type name 
    array( 
     'hierarchical' => true, 
     'label' => 'schedule categories', //Display name 
     'query_var' => true, 
     'rewrite' => array(
      'slug' => 'schedule_category', // This controls the base slug that will display before each term 
      'with_front' => false // Don't display the category base before 
     ) 
    ) );   } add_action('init', 'create_schedule_taxonomies'); 
+0

코드를 올바르게 포맷하십시오. –

0

나는 내 주제에서 같은 문제에 직면했다.

functions.php 파일에서 PHP 태그의 공백을 제거하십시오.

또는

원치 않는 플러그인을 제거하십시오.

+0

''PHP 태그에서 여분의 공백을 없애라 '는게 무슨 뜻입니까? – JSmith