Publish custom post types in WP

I’ve hit this problem a few times now and it’s not that obvious to solve.

Suppose you want to use custom post types in WordPress. As a real neat developer, you add your plugin or theme namespace to the name of your custom post time, something like this: mynicepluginname_podcasts (where podcasts is the actual custom post type name). After registering the custom post type, everything seems to be working. You have the podcasts show up in the CMS, there is an add button, but the list is still empty though. When you click on create new podcast, something strange happens: you don’t have a publish button, you can only send the podcast in for review!

What is happening? Well, it took me some time to find out, but apparently the post type name may not exceed 20 characters. This is documented in the WordPress codex as well, but easy to miss:

Do pay close attention to not having your namespace exceed 20 characters though, as the post_type column in the DB is currently a varchar field of the latter length.

So remember, keep your custom post type names short!