使用自定义模板时,自定义帖子类型的帖子不会显示

时间:2014-10-15 17:48:57

标签: php wordpress

这是我在注册帖子类型下的设置:

register_post_type( 'support', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */
    // let's now add all the options for this post type
    array( 'labels' => array(
        'name' => __( 'Support', 'bonestheme' ), /* This is the Title of the Group */
        'singular_name' => __( 'Support', 'bonestheme' ), /* This is the individual type */
        'all_items' => __( 'All support', 'bonestheme' ), /* the all items menu item */
        'add_new' => __( 'Add New', 'bonestheme' ), /* The add new menu item */
        'add_new_item' => __( 'Add New Support', 'bonestheme' ), /* Add New Display Title */
        'edit' => __( 'Edit', 'bonestheme' ), /* Edit Dialog */
        'edit_item' => __( 'Edit Support', 'bonestheme' ), /* Edit Display Title */
        'new_item' => __( 'New Support', 'bonestheme' ), /* New Display Title */
        'view_item' => __( 'View Support', 'bonestheme' ), /* View Display Title */
        'search_items' => __( 'Search Support', 'bonestheme' ), /* Search Custom Type Title */ 
        'not_found' =>  __( 'Nothing found in the Database.', 'bonestheme' ), /* This displays if there are no entries yet */ 
        'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ), /* This displays if there is nothing in the trash */
        'parent_item_colon' => ''
        ), /* end of arrays */
        'description' => __( 'This is the example for a slide', 'bonestheme' ), /* Custom Type Description */
        'public' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'show_ui' => true,
        'query_var' => true,
        'menu_position' => 8, /* this is what order you want it to appear in on the left hand side menu */ 
        'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png', /* the icon for the custom post type menu */
        'rewrite'   => array( 'slug' => 'support', 'with_front' => false ), /* you can specify its url slug */
        'has_archive' => 'custom_type', /* you can rename the slug here */
        'capability_type' => 'post',
        'hierarchical' => false,
        'taxonomies' => array('category'),
        /* the next one is important, it tells what's enabled in the post editor */
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky')
    ) /* end of options */
); /* end of register post type */  

在此自定义帖子类型下创建页面时,它们会被路由并正确永久链接。但是,当我加载页面时,会显示默认错误。

我还创建了single-support.php页面,目前它只是空白,因此我可以看到空白页面加载以确保其正常工作。

知道为什么这似乎不起作用?

1 个答案:

答案 0 :(得分:0)

来自wordpress帖子类型文档:

http://codex.wordpress.org/Post_Types

"注意:在某些情况下,必须更新永久链接结构以便新的 查看自定义帖子类型的帖子时要访问的模板文件。为此,请转到管理面板>设置>永久链接,将永久链接结构更改为不同的结构,保存更改,并将其更改回所需的结构。 "

这正是修复问题的原因。