Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

include("portfolio/portfolio-post-type.php"); 
include("gallery/gallery-post-type.php"); 

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?

share|improve this question

closed as too localized by Rarst Oct 14 '12 at 20:30

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 –  user1578481 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 –  user1578481 Oct 4 '12 at 18:32

1 Answer 1

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 __().

share|improve this answer
    
Thank you so much, changing the function names solve my problem. –  user1578481 Oct 5 '12 at 3:40

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