Gnanasekaran Loganathan
Gnanasekaran Loganathan

Reputation: 1108

Error while creating custom post type template

I create custom post type for works its content displayed using single.php but not dispalyed use single-dp_work.php

This is my function.php code it use to register custom post type 'work'

add_action( 'init', 'create_posttype' );
function create_posttype() { 
    register_post_type('dp_work', array(
        'labels' => array( 
            'name' => __( 'Work' ),
            'singular_name' => __( 'Work' ), 
            'add_new' => __( 'Add New' ),
            'add_new_item' => __( 'Add New Work' ),
            'edit' => __( 'Edit' ),
            'edit_item' => __( 'Edit Work' ),
            'new_item' => __( 'New Work' ),
            'view' => __( 'View Work' ),
            'view_item' => __( 'View Work' ),
            'search_items' => __( 'Search Work' ),
            'not_found' => __( 'No books found' ),
            'not_found_in_trash' => __( 'No books found in Trash' ),
            'parent' => __( 'Parent Work' )
        ),
        'public' => true, 
        'has_archive' => true,
        'supports' => array('title', 'editor', 'thumbnail','custom-fields'),
        'taxonomies' => array('category', 'post_tag'),
        'rewrite' => array('slug' => 'works')
    )); 
}

Upvotes: 0

Views: 79

Answers (1)

Yatendra
Yatendra

Reputation: 1306

You need to flush rewrite rules before this permalink work

function my_rewrite_flush() {
    flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );

Follow this http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation

Upvotes: 1

Related Questions