Title: Custom Post Type Permalink not working
Last modified: August 22, 2016

---

# Custom Post Type Permalink not working

 *  [coryvannote](https://wordpress.org/support/users/coryvannote/)
 * (@coryvannote)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-permalink-not-working/)
 * Hey,
 * I’ve been trying to troubleshoot this a while now, I’ve read a few other forums
   as well and none of those have helped so far. I’m adding a custom post type and
   taxonomy into my theme. The preview (before publishing) works with the correct
   single page, information and taxonomy as soon as I publish with post-name permalinks,
   it breaks and gives me a 404. If I switch back to default permalinks it works,
   but switching it back to fancy permalinks it breaks again. I’ve also tried adding
   a flush rewrite rules after creating the CPT, but that has not worked either.
   I’ve done CPT before in other themes and haven’t had this problem. Any suggestions?
   Code from my functions.php as follows:
 *     ```
       // ADDING BOOKS AS CUSTOM POST TYPE
       function books_post_type() {
       	$labels = array(
       		'name'				=> _x('Books', 'post type general name'),
       		'singular_name'		=> _x('Book', 'post type singular name'),
       		'add_new'			=> _x('Add New', 'book'),
       		'add_new_item'		=> __('Add New Book'),
       		'edit_item'			=> __('Edit Book'),
       		'new_item'			=> __('New Book'),
       		'all_items'			=> __('All Books'),
       		'view_item'			=> __('View Book'),
       		'search_items'		=> __('Search Books'),
       		'not_found'			=> __('No books found'),
       		'not_found'			=> __('No books found in the trash'),
       		'not_found'			=> __(''),
       		'menu_name'			=> __('Books')
       	);
       	$args = array(
       		'labels'			=> $labels,
       		'description'   	=> 'Holds each book information',
       		'public'        	=> true,
       		'menu_position' 	=> 5,
       		'hierarchical'		=> true,
       		'show_in_nav_menus'	=> true,
       		'supports'      	=> array( 'title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail', 'author', 'revisions' ),
       		'has_archive'   	=> true,
       	);
       	register_post_type('books', $args);
       }
       add_action('init', 'books_post_type');
   
       function books_taxonomy() {
       	$labels = array(
       		'name'              => _x( 'Book Categories', 'taxonomy general name' ),
       		'singular_name'     => _x( 'Book Category', 'taxonomy singular name' ),
       		'search_items'      => __( 'Search Book Categories' ),
       		'all_items'         => __( 'All Book Categories' ),
       		'parent_item'       => __( 'Parent Book Category' ),
       		'parent_item_colon' => __( 'Parent Book Category:' ),
       		'edit_item'         => __( 'Edit Book Category' ),
       		'update_item'       => __( 'Update Book Category' ),
       		'add_new_item'      => __( 'Add New Book Category' ),
       		'new_item_name'     => __( 'New Book Category' ),
       		'menu_name'         => __( 'Book Categories' )
       	);
       	$args = array(
       		'labels'			=> $labels,
       		'hierarchical' 		=> true,
       		'public'			=> true,
       		'show_in_nav_menus'	=> true,
       		'rewrite'			=> true
       	);
       	register_taxonomy( 'books_category', 'books', $args );
       }
       add_action( 'init', 'books_taxonomy', 0 );
       ```
   

The topic ‘Custom Post Type Permalink not working’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [custom theme](https://wordpress.org/support/topic-tag/custom-theme/)
 * [permalinks](https://wordpress.org/support/topic-tag/permalinks/)

 * 0 replies
 * 1 participant
 * Last reply from: [coryvannote](https://wordpress.org/support/users/coryvannote/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/custom-post-type-permalink-not-working/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
