Title: Problem Adding Second Custom Post Type to Functions.php
Last modified: August 20, 2016

---

# Problem Adding Second Custom Post Type to Functions.php

 *  [ben1000](https://wordpress.org/support/users/ben1000/)
 * (@ben1000)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problem-adding-second-custom-post-type-to-functionsphp/)
 * Hi there
 * I am trying to add my second custom post type to Functions.php and have copied
   exactly the same code as works for the first one, changing the relevant words
   to relate to the new one, and pasted it below. When I try to access the dashboard
   after uploading, I continually receive this error message:
 * Fatal error: Cannot redeclare codex_custom_init() (previously declared in /home/
   content/98/4487498/html/wp-content/themes/arthemia/functions.php:6) in /home/
   content/98/4487498/html/wp-content/themes/arthemia/functions.php on line 124
 * Any ideas?
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Jacob Chappell](https://wordpress.org/support/users/master-jake/)
 * (@master-jake)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problem-adding-second-custom-post-type-to-functionsphp/#post-2493043)
 * Looks to me like you’re re-using a function name (which you can’t do). Every 
   function must be unique and so you need to use some prefixes or suffixes to avoid
   collisions. For example, instead of using `codex_custom_init()` for your second
   post type, use something like `codex_custom_init_two()`
 *  [Troy Chaplin](https://wordpress.org/support/users/areziaal/)
 * (@areziaal)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problem-adding-second-custom-post-type-to-functionsphp/#post-2493045)
 * Alternatively, you can have multiple custom post type within the same function
   like this:
 *     ```
       <?php
   
       function codex_custom_init() {
   
       // FIRST POST TYPE
       	register_post_type('post-type-one', array(
       		// add info here
       	) );
   
       // SECOND POST TYPE
       	register_post_type('post-type-two', array(
       		// add info here
       	) );
   
       // IMPORTANT: Remember this line!
       flush_rewrite_rules( false );
       }
   
       // Initialise custom post type
       add_action('init', 'codex_custom_init', 1);
   
       ?>
       ```
   
 *  Thread Starter [ben1000](https://wordpress.org/support/users/ben1000/)
 * (@ben1000)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problem-adding-second-custom-post-type-to-functionsphp/#post-2493187)
 * Thanks!
 *  [Zukes](https://wordpress.org/support/users/zukes/)
 * (@zukes)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/problem-adding-second-custom-post-type-to-functionsphp/#post-2493276)
 * Thank you guys, really helpfull

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problem Adding Second Custom Post Type to Functions.php’ is closed to
new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [Zukes](https://wordpress.org/support/users/zukes/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/problem-adding-second-custom-post-type-to-functionsphp/#post-2493276)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
