• Resolved yolise

    (@yolise)


    I searched but it seems that others having this issue figure it out for themselves before anyone has a chance to reply and the solution never gets posted.

    Everytime I try to register a second post type, it breaks my function file. I assume this is because your can’t just duplicate the add_action init or the function name, but not being all that when it comes to php, I’m not sure which can and can’t be reused.

    Can someone explain how to register more than one custom post type?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I do it like this:

    function my_create_post_types() {
    	register_post_type( 'my_post_type', $args);
    	register_post_type( 'my_other_post_type', $args);
    }
    add_action( 'init', 'my_create_post_types' );
    Thread Starter yolise

    (@yolise)

    Ah, that’s the ticket! Thanks – I’m sure this will all make sense to me one day.

    I notice that your add_action init comes after the function. Mine’s before and it still seems to work. Does it matter?

    The order doesn’t matter. I just do it that way because it make more sense to my brain. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Registering multiple custom post types’ is closed to new replies.