Today while working on a WordPress site which has content imported from a drupal site using a plugin. That plugin imported content in various post types, so all the content are in database but I can’t see these in WordPress admin panel, because we don’t have the post types registered. The plugin just imported the content. Then after inspecting for a while, I’ve solved that with some simple coding. I thought it might be helpful for many users, so I’ve submitted the code as a plugin on wordpress.org . But this post is for those as well, who don’t want to use a plugin, instread they want to put the code inside Theme.
The piece of code I wrote basically checks database for all the post types and compare with registered post types on wordpress site. And then it registers the post types that are available in database but are not registered in WordPress.
Here’s the code which you can put in functions.php file of your active theme.
You can get the plugin from WordPress.org Repository by clicking here.
Let me know if you have any comments or suggestions!