티스토리 뷰
사용자 지정 게시 유형 = post type
사용자 지정 분류 = taxonomy
// init 액션에 연결하여 그 타이밍에 create_book_taxonomies를 호출
// add_action('init', 'create_book_taxonomies', 0);
// "book"사용자 정의 게시 유형에 genres와 writers 두 개의 사용자 정의 분류를 만들
function create_book_taxonomies() {
// (카테고리 같은) 계층화 된 사용자 분류를 새롭게 추가
$labels = array(
'name'=> _x('Genres', 'taxonomy general name')
'singular_name'=> _x('Genre', 'taxonomy singular name')
'search_items'=> __('Search Genres')
'all_items'=> __('All Genres')
'parent_item'=> __('Parent Genre')
'parent_item_colon'=> __('Parent Genre :')
'edit_item'=> __('Edit Genre')
'update_item'=> __('Update Genre')
'add_new_item'=> __('Add New Genre')
'new_item_name'=> __('New Genre Name')
'menu_name'=> __('Genre')
);
$args = array(
'hierarchical'=> true,
'labels'=> $labels,
'show_ui'=> true,
'show_admin_column'=> true,
'query_var'=> true,
'rewrite'=> array('slug'=> 'genre')
);
register_taxonomy('genre', array('book') $args);
// (태그와 같은) 계층이없는 사용자 분류를 새롭게 추가
$labels = array(
'name'=> _x('Writers', 'taxonomy general name')
'singular_name'=> _x('Writer', 'taxonomy singular name')
'search_items'=> __('Search Writers')
'popular_items'=> __('Popular Writers')
'all_items'=> __('All Writers')
'parent_item'=> null,
'parent_item_colon'=> null,
'edit_item'=> __('Edit Writer')
'update_item'=> __('Update Writer')
'add_new_item'=> __('Add New Writer')
'new_item_name'=> __('New Writer Name')
'separate_items_with_commas'=> __('Separate writers with commas')
'add_or_remove_items'=> __('Add or remove writers')
'choose_from_most_used'=> __('Choose from the most used writers')
'not_found'=> __('No writers found.')
'menu_name'=> __('Writers')
);
$args = 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'=> 'writer')
);
register_taxonomy('writer', 'book', $args);
}
기본적인 등록 예
add_action('init', 'create_book_tax'); function create_book_tax() { register_taxonomy( 'genre' 'book' array( 'label'=> __('Genre') 'rewrite'=> array('slug'=> 'genre') 'hierarchical'=> true, ) ); }
'웹프로그래밍 > Wordpress' 카테고리의 다른 글
| 워드프레스 CRUD (0) | 2015.01.05 |
|---|---|
| 워드프레스 index.php 부터 코드 흐름 (0) | 2015.01.05 |
| 워드프레스 훅 - 액션/필터 (0) | 2015.01.05 |
| 워드프레스 함수 (0) | 2015.01.05 |
| 워드프레스 글번호 얻기 (0) | 2015.01.05 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- ASP
- iphone
- git
- classic asp
- centos
- CSS
- macos
- 워드프레스
- IE
- 한글
- 안드로이드
- Android
- IOS
- Debug
- nodejs
- sencha touch
- Mac
- javascript
- nginx
- Prototype
- API
- laravel
- JSON
- JQuery
- Docker
- mssql
- iis
- Wordpress
- Linux
- PHP
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함