veya eklentisiz örnek olarak;
add_action('init', 'filmler_register');
function filmler_register() {
$labels = array(
'name' => _x('Filmler', 'post type general name'),
'singular_name' => _x('filmler Item', 'post type singular name'),
'add_new' => _x('Film Ekle', 'filmler item'),
'add_new_item' => __('Yeni Film Ekle'),
'edit_item' => __('Film Düzenle'),
'new_item' => __('New filmler Item'),
'view_item' => __('Filmi Görüntüle'),
'search_items' => __('Filmlerde Ara'),
'not_found' => __('Bulunamadı'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => '',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'post-formats', array( 'aside', 'gallery', 'link' ),
'supports' => array('title','editor','thumbnail' )
);
register_post_type( 'filmler' , $args );
}
register_taxonomy("Kategoriler", array("filmler"), array("hierarchical" => true, "label" => "Kategoriler", "singular_label" => "Kategoriler", "rewrite" => true));
add_action("admin_init", "admin_init");
function admin_init(){
add_meta_box("year_completed-meta", "Yapım yılı", "year_completed", "filmler", "normal", "low");
add_meta_box("credits_meta", "Detaylar", "credits_meta", "filmler", "normal", "low");
}
function year_completed(){
global $post;
$custom = get_post_custom($post->ID);
$year_completed = $custom["year_completed"][0];
?>
}
function credits_meta() {
global $post;
$custom = get_post_custom($post->ID);
$extra1 = $custom["extra1"][0];
$extra2 = $custom["extra2"][0];
$extra2 = $custom["extra2"][0];
?>
}
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "year_completed", $_POST["year_completed"]);
update_post_meta($post->ID, "extra1", $_POST["extra1"]);
update_post_meta($post->ID, "extra2", $_POST["extra2"]);
update_post_meta($post->ID, "extra2", $_POST["extra2"]);
}
add_action("manage_posts_custom_column", "filmler_custom_columns");
add_filter("manage_edit-filmler_columns", "filmler_edit_columns");
function filmler_edit_columns($columns){
$columns = array(
"cb" => "",
"title" => "Başlık",
"description" => "Açıklama",
"year" => "Yapım Yılı",
"kategoriler" => "Kategoriler",
);
return $columns;
}
function filmler_custom_columns($column){
global $post;
switch ($column) {
case "description":
the_excerpt();
break;
case "year":
$custom = get_post_custom();
echo $custom["year_completed"][0];
break;
case "kategoriler":
echo get_the_term_list($post->ID, 'Kategoriler', '', ', ','');
break;
}
}
?>