Search code examples
phpwordpresscategoriesposts

Wordpress: Register existing custom post type?


I've been struggling on using the same categories used on regular posts on custom posts, so I can query custom posts based on categories too.

Thing is, the custom posts weren't created using register_post_type at all, they are created by just using wp_insert_post with a different post type, forcingly creating a new type that doesn't support categories at all, so querying with categories has no use. The page is live, so there are a few important custom posts in the database already, without support for categories.

So, if I made a call to register_post_type in init now (to add categories by adding the 'taxonomies' => array('category') parameter, would new custom posts be queriable, without destroying the old, existing posts in the database? Or should I try something else entirely?

I've thought about using meta data for the custom posts, but I want to keep integrity between regular and custom's categories.

Thanks for the attention.


Solution

  • register_post_type is mostly used so the post type is displayed in your wp-admin. It will not affect your current database records.