0
我注册了自定义的帖子类型,并将它们放在它自己的子目录下。这工作正常,但如果我点击子目录本身,它会返回一个404.我的问题是如何将子目录注册为模板。我试过为那个slu creating创建一个页面模板,但不幸的是,该特定的目录没有注册。下面是我做了什么:Wordpress CPT子目录
add_action('init', 'create_post_type');
function create_post_type() {
$postNames = array('NZ-Music', 'Movie-Reviews', 'NZ-Fashion', 'Fashion-Trends', 'Beauty-Tips', 'Beauty-Products', 'Beauty-Trends', 'Gift-Ideas', 'New-Restaurant', 'Restaurant-Review');
foreach ($postNames as $postType) {
$lowerCase = strtolower($postType);
$replaceSpace = str_replace("-", " ", $postType);
register_post_type($postType,
array(
'labels' => array(
'name' => __($replaceSpace),
'singular_name' => __($postType)
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-' . $lowerCase,
'rewrite' => $postType . "/" . $postType,
'public' => true,
'has_archive' => $postType . "/" . $postType,
)
);
}
}
对于NZ-音乐的URI会是这个样子:/ NZ-音乐/后 并且将返回岗位。但是,当我尝试搜索/ nz-music时,这将返回404.任何想法?
干杯!