WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating several custom post types, do I need to keep the register_post_type calls in functions.php? I would assume that this would only need to be run the once then removed, or do I need to keep the calls there?

share|improve this question
up vote 1 down vote accepted

Yes, you need to keep it within functions.php and within the init hook, as it will have to register each time. It's not like with roles, where you can add it once and it's saved in the database.

share|improve this answer

I do agree with @Simon, that you should consider to use your custom plugin - as it's a best practise. It's as easy as creating your functions.php.

What's more, you should take in consideration a Must use plugin. Again, it's not complicated and it provides the assurance your custom plugin containing your custom taxonomies and post types (hand coded) get's loaded.

share|improve this answer
When you say assurances, are you talking about theme changes? or something else? (thanks for the wpmu link, not come across them before) – BillyMedia Feb 10 '13 at 12:31
By "the assurance" I mean that the plugin is always loaded and can not be deactivated from the administration. Thus, all custom taxonomies, custom post types, shortcodes and other things which should go to the site specific plugin. You can read more in here: wpbeginner.com/beginners-guide/… or here: bravenewcode.com/2012/04/… – david.binda Feb 10 '13 at 13:20
Good to know, is the Must-Use Plugins Folder (wp-content > mu-plugins) also works on a "stand-alone" WP instance ? – Simon Feb 10 '13 at 18:31
yep, it does work on single blog installation. See codex.wordpress.org/Must_Use_Plugins#History_and_Naming – david.binda Feb 10 '13 at 18:46

As PHP is stateless, CPT needs to be runs for each thread and its code needs to stay permanently.

However, this leads me to the reason of my anser : instead of creating CPT in functions.php, best practice would be to create a plugin. The idea is if you need to change theme at some point, you will "loose" CPT ; so using a plugin allow you to have liberty of changing theme without loosing CPT data and admin UI.

share|improve this answer
I try and limit plugin use so code things like custom taxonomies and post types myself. But i see your point. – BillyMedia Feb 10 '13 at 11:40
I meant custom-built plugin, of course, for your own and only use. It's just the matter of where to place the code. – Simon Feb 10 '13 at 11:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.