Quantcast
Channel: BIOSTALL » PHP
Viewing all articles
Browse latest Browse all 57

WordPress Custom Post Type Not Appearing In Backend

$
0
0

I’ve just experienced a problem when working on a WordPress website whereby I registered a custom post type in functions.php, however I could not get it to display in the left hand navigation. I received no errors at all, the post type would just not display.

My code was as follows:

add_action( 'init', 'create_post_types' );
function create_post_types() {
	register_post_type( 'homepage_large_panels',
		array(
			'labels' => array(
				'name' => __( 'Homepage Large Panels' ),
				'singular_name' => __( 'Homepage Large Panels' )
			),
		'public' => true
		)
	);
}

The Solution

After a bit of trial and error, plus further research, I found the following snippet from the WordPress documentation:

$post_type
(string) (required) Post type. (max. 20 characters, can not contain capital letters or spaces)
Default: None

The $post_type parameter I was using in the code above was 21 characters long so, after changing it to something less than 20 characters, it began to show immediately.


Viewing all articles
Browse latest Browse all 57

Trending Articles