Hi i want to include 2 different custom post types in my functions files:


But they seem to break WordPress, it only works if I include only one at a time, do I need to wrap this within a function?

  • what do those files contain?
    – Milo
    Oct 4 '12 at 17:44
  • this is what os included on each file(with different names for the post type):cl.ly/393s2U1N2z0b Oct 4 '12 at 18:19
  • can you post each file (separately) exactly as is on pastebin.com ? Alos tell us exactly what the error message is. If you have non, use WP_DEBUG to discover it
    – Tom J Nowell
    Oct 4 '12 at 18:23
  • ok here re the two:pastebin.com/q0x9Mp7E pastebin.com/3tiW2RN1 Oct 4 '12 at 18:32

The reason you can't include both files is that you've named all the functions the same. You can't have two functions named post_type or portfolio_messages etc.

Also I see a few other things wrong with your code.

  • The function names should be unique to your plugin/theme. So prepend the names with your theme/plugin name. So try mytheme_gallery_post_type and mytheme_portfolio_post_type etc.

  • The rewrite array should not be a part of $labels. Make it a part of $args instead.

  • Don't run the taxonomy and custom post type names through the internationalization function. That is the first arg to register_post_type and register_taxonomy should not be run through __().

  • Thank you so much, changing the function names solve my problem. Oct 5 '12 at 3:40

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