반응형
커스텀 투고 타입에 기본 카테고리/태그 분류법을 재사용하시겠습니까?
내 워드프레스 테마에서functions.php, 라고 하는 커스텀 투고 타입을 작성했습니다.foobar.
를 재사용할 수 있습니까?defaultfoobar 게시물에 대한 카테고리 및 태그?또는 다음 두 가지 분류법을 작성해야 합니까?
- 카테고리용 1
- 태그의 다른 쪽
어떻게 해야 할까요?
편집: 커스텀 투고 타입을 작성하는 함수 내에서 다음 코드를 사용하여 이 문제를 해결했다고 생각합니다.
register_taxonomy_for_object_type('category', 'foobar');
register_taxonomy_for_object_type('post_tag', 'foobar');
당신은 일석이조의 효과를 얻을 수 있다.taxonomies키를 눌러 투고 유형을 등록합니다.
$product_labels = array(
'name' => _x('Products', 'post type general name'),
'singular_name' => _x('Product', 'post type singular name'),
'add_new' => _x('Add New', 'portfolio item'),
'add_new_item' => __('Add New Product'),
'edit_item' => __('Edit Product'),
'new_item' => __('New Product'),
'view_item' => __('View Product'),
'search_items' => __('Search Products'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$product_args = array(
'labels' => $product_labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'product'),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 2,
'supports' => array('title','editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions', 'page-attributes', 'custom-fields', ),
// Set the available taxonomies here
'taxonomies' => array('category', 'post_tag')
);
register_post_type('product', $product_args);
언급URL : https://stackoverflow.com/questions/6258996/re-use-default-categories-tags-taxonomies-for-custom-post-type
반응형
'programing' 카테고리의 다른 글
| JsonNode에 새 노드를 만드는 방법 (0) | 2023.03.06 |
|---|---|
| gson이 Malformed Json Exception을 슬로우하다 (0) | 2023.03.06 |
| add_filter('wp_title')는 타이틀 태그(WordPress 플러그인)를 대체하지 않습니다. (0) | 2023.02.11 |
| 리액트 라우터가 404 상태 코드로 응답하도록 하려면 어떻게 해야 합니까? (0) | 2023.02.11 |
| 도커 구성 볼륨 사용 권한 리눅스 (0) | 2023.02.11 |