Reputation: 237
Here is the code, the 5th and final one is not showing up in the ADMIN CP Panel. All the others are working fine, but when I try add a 5th one. Nothing shows up. Not sure if there is a limit or something, does not appear to be from what I have read.
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'Slides',
array(
'labels' => array(
'name' => __( 'slides' ),
'singular_name' => __( 'slide' )
),
'public' => true,
'has_archive' => true,
)
);
register_post_type( 'Programs',
array(
'labels' => array(
'name' => __( 'programs' ),
'singular_name' => __( 'program' )
),
'public' => true,
'has_archive' => true,
)
);
register_post_type( 'Boards',
array(
'labels' => array(
'name' => __( 'Boards' ),
'singular_name' => __( 'sponsor' )
),
'public' => true,
'has_archive' => true,
)
);
Upvotes: 1
Views: 138
Reputation: 254072
Your code just work perfectly, you have just forget in your code at the end a closing bracket }
and some errors in slug post types (in lowercase):
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'slides', // <== here to lowercase (slug)
array(
'labels' => array(
'name' => __( 'Slides' ), // <== here 1st letter uppercase
'singular_name' => __( 'Slide' ) // <== here 1st letter uppercase
),
'public' => true,
'has_archive' => true,
)
);
register_post_type( 'programs', // <== here to lowercase (slug)
array(
'labels' => array(
'name' => __( 'Programs' ), // <== here 1st letter uppercase
'singular_name' => __( 'Program' ) // <== here 1st letter uppercase
),
'public' => true,
'has_archive' => true,
)
);
register_post_type( 'boards', // <== here to lowercase (slug)
array(
'labels' => array(
'name' => __( 'Boards' ),
'singular_name' => __( 'Board' ) // <== here singular
),
'public' => true,
'has_archive' => true,
)
);
} // <== forgetted this
I have test your code on a test website and even your custom post "Boards" is showing and working:
You may need to flush the rewrite rules by going on backend permalinks settings and simply click on save to regenerate Wordpress rewrite rules related to this new post types…
Is there a limit for post types in WordPress?
There is no limit for number of different custom posts. Try the example below that generates in a very compact code 10 custom posts with a for loop :
add_action( 'init', 'create_post_type' );
function create_post_type() {
$arr = array('abcdef','bcdefg','cdefgh','defghi','efghij','fghijk','ghijkl','hijklm','ijklmn','jklmno');
for( $i = 0; $i < 10; $i++ ) {
$slug = $arr[$i];
$slugs = $arr[$i].'s';
register_post_type( $slug,
array(
'labels' => array(
'name' => $slugs,
'singular_name' => $slug ),
'public' => true,
'has_archive' => true )
);
}
}
References:
Upvotes: 2