Terrorpixel1991
3/31/2016 - 2:05 PM

Add Custom Post Type

Add Custom Post Type

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'CUSTOM_POST_TYPE_NAME',
    array(
      'labels' => array(
        'name' => __( 'NAME PLURAL' ),
        'singular_name' => __( 'NAME SINGULAR' )
      ),
      'public' => true,
      'has_archive' => true,
      'menu_icon' => 'dashicons-layout',
      'rewrite' => array ('slug' => 'DOMAIN SLUG'),
      'supports' => array (
      	'title',
      	'editor',
      	'excerpt',
      	'thumbnail',
      	'category',
      	'custom-fields',
      	'revisions' ),
      'taxonomies' => array('category')
    )
  );
}
// Fügt Kategorien zum Custom Post Type hinzu

add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
	register_taxonomy(
		'categories',
		'CUSTOM_POST_TYPE_NAME',
		array(
			'hierarchical' => true,
			'label' => 'NAME DER KATEGORIE',
			'query_var' => true,
			'rewrite' => true
			)
		);
}