Last active
October 4, 2017 03:08
-
-
Save Aziz-Rahman/0ee33e8e95b47571c2f5 to your computer and use it in GitHub Desktop.
Custom Post Type & Custom Taxonomy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Post Type Pegawai | |
* | |
* @package WordPress | |
* @subpackage Latihan | |
* @since Latihan 1.0 | |
*/ | |
?> | |
<?php | |
function create_pegawai(){ | |
$labels = array( | |
'name' => 'Pegawai', | |
'singular' => 'Pegawai', | |
'add_new' => 'Add New', | |
'add_new_item' => 'Add New Pegawai', | |
'edit_item' => 'Edit Pegawai', | |
'search_items' => 'Search Pegawai', | |
'not_found' => 'Tidak ada data pegawai !' | |
); | |
$supports = array( | |
'title', | |
'author', | |
'editor', | |
'custom-field', | |
'excerpt', | |
'thumbnail' | |
); | |
register_post_type( 'pegawai', | |
array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable'=> true, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'pegawai-negeri', 'with_front' => true ), | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'menu_position' => 30, | |
'supports' => $supports | |
) | |
); | |
} | |
add_action( 'init', 'create_pegawai' ); | |
?> | |
<?php | |
/** | |
* Custom Post Type Siswa | |
* | |
* @package WordPress | |
* @subpackage Latihan | |
* @since Latihan 1.0 | |
*/ | |
?> | |
<?php | |
function create_siswa(){ | |
$labels = array( | |
'name' => 'Siswa', | |
'singular' => 'siswa', | |
'add_new' => 'Add New', | |
'add_new_item' => 'Add New siswa', | |
'edit_item' => 'Edit siswa', | |
'search_items' => 'Search siswa', | |
'not_found' => 'Tidak ada data siswa !' | |
); | |
$supports = array( | |
'title', | |
'author', | |
'editor', | |
'custom-field', | |
'excerpt' | |
); | |
register_post_type( 'siswa', | |
array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable'=> true, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'siswa-siswi', 'with_front' => true ), | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'menu_position' => 30, | |
'supports' => $supports | |
) | |
); | |
} | |
add_action( 'init', 'create_siswa' ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Taxonomy Divisi from Custom Post Type Pegawai | |
* | |
* @package WordPress | |
* @subpackage Latihan | |
* @since Latihan 1.0 | |
*/ | |
?> | |
<?php | |
function create_divisi_taxonomy() { | |
$labels = array( | |
'name' => 'Nama divisi', | |
'singular_name' => 'Divisi', | |
'search_items' => 'Cari divisi', | |
'popular_items' => 'divisi Populer', | |
'all_items' => 'Semua divisi', | |
'edit_item' => 'Edit divisi', | |
'update_item' => 'Ubah divisi', | |
'add_new_item' => 'Tambah divisi', | |
'new_item_name' => 'Nama divisi Baru', | |
'add_or_remove_items' => 'Tambah atau Hapus divisi', | |
'menu_name' => 'Divisi Pegawai' | |
); | |
register_taxonomy( 'divisi', 'pegawai', | |
array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'query_var' => true, | |
) ); | |
} | |
add_action('init', 'create_divisi_taxonomy'); | |
?> | |
<?php | |
/** | |
* Taxonomy Kelas from Custom Post Type Siswa | |
* | |
* @package WordPress | |
* @subpackage Latihan | |
* @since Latihan 1.0 | |
*/ | |
?> | |
<?php | |
function create_kelas_taxonomy() { | |
$labels = array( | |
'name' => 'Nama kelas', | |
'singular_name' => 'Kelas', | |
'search_items' => 'Cari kelas', | |
'popular_items' => 'Kelas Populer', | |
'all_items' => 'Semua kelas', | |
'edit_item' => 'Edit kelas', | |
'update_item' => 'Ubah kelas', | |
'add_new_item' => 'Tambah kelas', | |
'new_item_name' => 'Nama kelas Baru', | |
'add_or_remove_items' => 'Tambah atau Hapus kelas', | |
'menu_name' => 'Kelas' | |
); | |
register_taxonomy( 'kelas', 'siswa', | |
array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'query_var' => true, | |
) ); | |
} | |
add_action('init', 'create_kelas_taxonomy'); | |
?> | |
<?php | |
/** | |
* Taxonomy Jurusan from Custom Post Type Siswa | |
* | |
* @package WordPress | |
* @subpackage Latihan | |
* @since Latihan 1.0 | |
*/ | |
?> | |
<?php | |
function create_jurusan_taxonomy() { | |
$labels = array( | |
'name' => 'Nama jurusan', | |
'singular_name' => 'jurusan', | |
'search_items' => 'Cari jurusan', | |
'popular_items' => 'Jurusan Populer', | |
'all_items' => 'Semua jurusan', | |
'edit_item' => 'Edit jurusan', | |
'update_item' => 'Ubah jurusan', | |
'add_new_item' => 'Tambah jurusan', | |
'new_item_name' => 'Nama jurusan Baru', | |
'add_or_remove_items' => 'Tambah atau Hapus jurusan', | |
'menu_name' => 'Jurusan' | |
); | |
register_taxonomy( 'jurusan', 'siswa', | |
array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'query_var' => true, | |
) ); | |
} | |
add_action('init', 'create_jurusan_taxonomy'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment