반응형
태그 패널을 커스텀 투고 타입으로 표시
방금 맞춤 우편물 타입을 만들었어요.포스트 타입과 같은 태그 패널을 사이드바에 표시하려면 어떻게 해야 합니까?
이 행을 사용자 섹션에 추가합니다.register_post_type기능하고 있습니다.테마 폴더에 php가 있습니다.
'taxonomies' => array('category', 'post_tag')
전체 코드는 다음과 같습니다.
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'posttypename',
array(
'labels' => array(
'name' => __( 'PostTypeName' ),
'singular_name' => __( 'PostTypeName' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'posttypename'),
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail' ),
'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
)
);
}
사용하시는 경우'taxonomies' => array('category', 'post_tag')그러면 wordpress 기본 투고 태그가 사용자 지정 투고 유형 영역에 표시됩니다.
다음은 "뉴스" 투고 유형을 위한 깨끗하고 독특한 방법입니다.다른 사용자 지정 게시 유형, 기본 태그 등과 함께 사용할 수 없습니다.
이 링크에서 "카테고리가 있는 사용자 지정 게시물 유형 및 태그 만들기"에 대한 전체 세부 정보를 확인할 수 있습니다.
add_action( 'init', 'news_tag_taxonomies' ); //change order add_action( 'init', 'news_tag_taxonomies', 0 );
//create two taxonomies, genres and tags for the post type "tag"
function news_tag_taxonomies()
{
// Add new taxonomy, NOT hierarchical (like tags)
$labels = array(
'name' => _x( 'Tags', 'taxonomy general name' ),
'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
'search_items' => __( 'Search Tags' ),
'popular_items' => __( 'Popular Tags' ),
'all_items' => __( 'All Tags' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Tag' ),
'update_item' => __( 'Update Tag' ),
'add_new_item' => __( 'Add New Tag' ),
'new_item_name' => __( 'New Tag Name' ),
'separate_items_with_commas' => __( 'Separate tags with commas' ),
'add_or_remove_items' => __( 'Add or remove tags' ),
'choose_from_most_used' => __( 'Choose from the most used tags' ),
'menu_name' => __( 'Tags' ),
);
register_taxonomy('tag','news',array( // replace your post type with "news"
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'tag' ),
));
}
이게 도움이 됐으면 좋겠어요.
기본 WP codex 템플릿과 별도로 추가할 필요가 있는 것은
'taxonomies' => array('post_tag'),
언급URL : https://stackoverflow.com/questions/10245071/show-tag-panel-in-custom-post-type
반응형
'sourcecode' 카테고리의 다른 글
| 업로드된 이미지와 동일한 크기의 미리 보기를 생성하도록 Wordpress를 강제 (0) | 2023.02.07 |
|---|---|
| Woocommerce Ajax가 프로그래밍 방식으로 카트에 추가 (0) | 2023.02.07 |
| Wordpress(3.8) 관리 UI 스타일 CSS 클래스 (0) | 2023.02.07 |
| Python: json.loads는 'u'가 붙은 항목을 반환합니다. (0) | 2023.02.07 |
| Wordpress 관리자 페이지에 템플릿 드롭다운이 표시되지 않음 (0) | 2023.02.07 |