How to create a Custom Post Type?

In some cases it is advisable to create your own custom post types. This is an extension for content, whereby this content is not fixed to a certain type. The following code snippet creates a Custom Post Type for contact persons and at the same time creates a category tree for them.

function ansprechpartner_post_type() {
$labels = array(
'name' => 'Ansprechpartner Einträge',
'singular_name' => 'Ansprechpartner',
'menu_name' => 'Ansprechpartner',
'parent_item_colon' => '',
'all_items' => 'Alle Einträge',
'view_item' => 'Eintrag ansehen',
'add_new_item' => 'Neuer Eintrag',
'add_new' => 'Hinzufügen',
'edit_item' => 'Eintrag bearbeiten',
'update_item' => 'Update Eintrag',
'search_items' => '',
'not_found' => '',
'not_found_in_trash' => '',
);
$rewrite = array(
'slug' => 'neuer_ansprechpartner',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'trackbacks', ),
'taxonomies' => array('post_tag'),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => false,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'neuer_ansprechpartner', $args );
}
add_action( 'init', 'ansprechpartner_post_type', 0 );

add_action( 'init', 'ansprechpartner_post_type_custom_taxonomy', 0 );
function ansprechpartner_post_type_custom_taxonomy() {
  $labels = array(
    'name' => _x( 'Abteilungen', 'taxonomy general name' ),
    'singular_name' => _x( 'Abteilung', 'taxonomy singular name' ),
    'search_items' =>  __( 'Abteilung suchen' ),
    'all_items' => __( 'Alle Abteilungen' ),
    'parent_item' => __( 'Kategorie' ),
    'parent_item_colon' => __( 'Parent Type:' ),
    'edit_item' => __( 'Abteilung bearbeiten' ), 
    'update_item' => __( 'Aktualisieren' ),
    'add_new_item' => __( 'Neu hinzufügen' ),
    'new_item_name' => __( 'New Type Name' ),
    'menu_name' => __( 'Abteilungen' ),
  ); 	
  register_taxonomy('abteilungen',array('neuer_ansprechpartner'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'abteilung' ),
  ));
}