• Resolved Robert

    (@hartlrobert)


    I want to use two custom post types. The first one works as expected, the second one does not appear. No error message. I’ve the code from the great custom post type generator.
    functions.php excerpt below. I don’t know, what could be wrong.
    Thank you very much!

    // Posttype1
    add_action( 'init', 'register_cpt_posttype1' );
    function register_cpt_posttype1() {
    	$labels = array(
    	'name' => _x( 'Posttype1', 'posttype1' ),
    	'singular_name' => _x( 'Posttype1', 'posttype1' ),
    	'add_new' => _x( 'Add', 'posttype1' ),
    	'add_new_item' => _x( 'New Posttype1', 'posttype1' ),
    	'edit_item' => _x( 'Posttype1 edit', 'posttype1' ),
    	'new_item' => _x( 'New Posttype1', 'posttype1' ),
    	'view_item' => _x( 'Posttype1 ansehen', 'posttype1' ),
    	'search_items' => _x( 'Posttype1 durchsuchen', 'posttype1' ),
    	'not_found' => _x( 'No posttype1 found', 'posttype1' ),
    	'not_found_in_trash' => _x( 'No posttype1 found in Trash', 'posttype1' ),
    	'parent_item_colon' => _x( 'Parent Posttype1:', 'posttype1' ),
    	'menu_name' => _x( 'Posttype1', 'posttype1' ),
    	);
    	$args = array(
    	'labels' => $labels,
    	'hierarchical' => false,
    	'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'page-attributes' ),
    	'taxonomies' => array( 'category' ),
    	'public' => true,
    	'show_ui' => true,
    	'show_in_menu' => true,
    	'menu_position' => 15,
    	'show_in_nav_menus' => true,
    	'publicly_queryable' => true,
    	'exclude_from_search' => true,
    	'has_archive' => false,
    	'query_var' => true,
    	'can_export' => true,
    	'rewrite' => array(
    	'slug' => 'posttype1',
    	'with_front' => false,
    	'feeds' => false,
    	'pages' => true
    	),
    	'capability_type' => 'post'
    	);
    	register_post_type( 'posttype1', $args );
    }
    
    // Posttype2
    add_action( 'init', 'register_cpt_posttype2' );
    function register_cpt_posttype2() {
    	$labels = array(
    	'name' => _x( 'Posttype2', 'posttype2' ),
    	'singular_name' => _x( 'Posttype2', 'posttype2' ),
    	'add_new' => _x( 'Posttype2 hinzufügen', 'posttype2' ),
    	'add_new_item' => _x( 'Neuen Posttype2 hinzufügen', 'posttype2' ),
    	'edit_item' => _x( 'Posttype2 bearbeiten', 'posttype2' ),
    	'new_item' => _x( 'Neuer Posttype2', 'posttype2' ),
    	'view_item' => _x( 'Posttype2 ansehen', 'posttype2' ),
    	'search_items' => _x( 'Posttype2 suchen', 'posttype2' ),
    	'not_found' => _x( 'Kein Posttype2 gefunden', 'posttype2' ),
    	'not_found_in_trash' => _x( 'No tennisschl?ger found in Trash', 'posttype2' ),
    	'parent_item_colon' => _x( 'Parent Posttype2:', 'posttype2' ),
    	'menu_name' => _x( 'Posttype2', 'posttype2' ),
    	);
    	$args = array(
    	'labels' => $labels,
    	'hierarchical' => false,
    	'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
    	'taxonomies' => array( 'category', 'post_tag', 'lexikon' ),
    	'public' => true,
    	'show_ui' => true,
    	'show_in_menu' => true,
    	'menu_position' => 5,
    	'show_in_nav_menus' => true,
    	'publicly_queryable' => true,
    	'exclude_from_search' => false,
    	'has_archive' => false,
    	'query_var' => true,
    	'can_export' => true,
    	'rewrite' => array(
    	'slug' => 'posttype2',
    	'with_front' => false,
    	'feeds' => true,
    	'pages' => true
    	),
    	'capability_type' => 'post'
    	);
    	register_post_type( 'posttype2', $args );
    }

    Anyone found an error? Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Code looks fine. Are you using a plugin to generate this code? If you are, try deactivating the plugin, and pasting that code into your funtions.php file.

    Thread Starter Robert

    (@hartlrobert)

    thank you, no that’s the code in my functions.php. I just use the external generator to generate the codes.
    Hm, so this is caused by a plugin or other code in my functions. Yeah.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Second register custom post type doesn't work’ is closed to new replies.