我的网站上有一个名为“个人资料”的类别,我正在将该类别移至名为“个人资料”的自定义帖子类型。
我的问题是我无法显示此自定义帖子类型的存档页面。当我转到url时mywebsite.com/profiles
,将我带到个人资料类别中某个帖子的单个帖子页面。
我已经包括has_archive = true;
在我的functions.php
我在同一个网站上为另一个自定义帖子类型创建存档页面时没有问题,所以我真的迷失了为什么这次无法正常工作。
任何建议将不胜感激?
add_action( 'init', 'profile_custom_init' );
/* Here's how to create your customized labels */
function profile_custom_init() {
$labels = array(
'name' => _x( 'Profiles', 'post type general name' ), // Tip: _x('') is used for localization
'singular_name' => _x( 'Profile', 'post type singular name' ),
'add_new' => _x( 'Add New', 'Profile' ),
'add_new_item' => __( 'Add Profile' ),
'edit_item' => __( 'Edit Profile' ),
'new_item' => __( 'New Profile' ),
'view_item' => __( 'View Profile' ),
'search_items' => __( 'Search Profile' ),
'not_found' => __( 'No Profile found' ),
'not_found_in_trash' => __( 'No Profile found in Trash' ),
'parent_item_colon' => ''
);
// Create an array for the $args
$args = array( 'labels' => $labels, /* NOTICE: the $labels variable is used here... */
'public' => true,
'publicly_queryable' => true,
'has_archive' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 10,
'supports' => array( 'title', 'editor','thumbnail', 'excerpt', 'custom-fields' ),
'taxonomies' => array('category')
);
register_post_type( 'profile', $args ); /* Register it and move on */
}
尝试将个人档案类别标签更改为其他个人档案(例如,profiles-2)。
—
Vinod Dalvi
似乎不起作用。另外,例如,如果我转到mywebsite.com/his网址,而不是将我带到404页(我没有任何页面或帖子仅称为“ His”),它将带我到以“ his”一词开头的帖子。这看起来很奇怪吗?
—
13年
您是否尝试过再次保存永久链接结构?这将导致重新生成重写规则。
—
Mike Madern 2013年
通过单击“永久链接设置”的“保存更改”按钮,尝试重新保存永久链接结构。
—
Vinod Dalvi