[英]Wordpress Custom Post Type Archives
I have added the following to my functions.php file 我已将以下内容添加到我的functions.php文件中
register_post_type( 'news',
array(
'labels' => array(
'name' => __( 'News' ),
'singular_name' => __( 'News' ),
'add_new' => __( 'Add New Article' ),
'add_new_item' => __( 'Add Article' ),
'edit_item' => __( 'Edit Article' ),
'new_item' => __( 'New Article' ),
'view_item' => __( 'View Article' ),
'search_items' => __( 'Search Articles' ),
'not_found' => __( 'No Articles Found' ),
'not_found_in_trash' => __( 'No Articles Found In Trash' ),
'rewrite' => array(
'slug' => 'news',
'with_front' => false
),
'has_archive' => true,
),
'public' => true,
)
); );
But when i type in news after my site mysite/news/ I get a page not found when it should I gather be listing my archives for news with the has_archives option. 但是当我在我的网站mysite / news /我得到一个未找到的页面后输入新闻时,我应该收集使用has_archives选项列出我的档案以获取新闻。
What am I doing wrong!!! 我究竟做错了什么!!!
By the way I have an archives.php file 顺便说一句,我有一个archives.php文件
Go into permalinks and save the settings to refresh the permalink structure. 进入永久链接并保存设置以刷新永久链接结构。 Wordpress has a problem with the custom post type permalinks you have to do this every time you make a change to you custom post type. Wordpress有自定义帖子类型固定链接的问题,每次你对自定义帖子类型进行更改时都必须这样做。 This will prevent your from getting a 404 error. 这样可以防止您收到404错误。
Solved its not actually been released yet, the feature. 解决了它尚未发布的功能。 I had to download the beta version however this version of wordpress is due soon. 我不得不下载测试版,但是这个版本的wordpress即将推出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.