我创建了自定义帖子类型,用于使用single.php
显示的内容,但没有显示使用single-dp_work.php
这是我用来注册自定义帖子类型的function.php
代码' 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')
));
}
答案 0 :(得分:1)
在此永久链接工作之前,您需要刷新重写规则
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
按照这个 http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation