我在我的主题上创建了一个定制的post类型(deals)、术语(项目)、菜单(top_menu)和归档页面( archive actions.php)。我想在存档页面中显示术语帖子列表。但是,当我单击“术语”菜单时,然后重定向以下链接:http://localhost/wordpress/chorui/project/html-3/并显示错误消息页“找不到”。
<?php
// Custom post and terms
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'deals',
array(
'labels' => array(
'name' => __( 'Deals' ),
'singular_name' => __( 'Deal' )
),
'public' => true,
'has_archive' => true,
'hierarchical' => true
)
);
}
register_taxonomy("project", array("deals"), array("hierarchical" => true, "label" => "Project Types", "singular_label" => "Project Type", "rewrite" => true));
?>
<?php
// archive-deals.php
get_header();
wp_nav_menu(array(
'theme_location' => 'top_menu',
'container' => 'nav',
'container_class' => 'top_menu',
'fallback_cb' => false,
'items_wrap' => '<ul>%3$s</ul>'
));
/* Start the Loop */
while ( have_posts() ) : the_post();
//This will return the content of the CPT archive
get_template_part( 'content', get_post_format());
endwhile;
if ( function_exists('wp_bootstrap_pagination') ) {
wp_bootstrap_pagination();
}
get_footer();
?>发布于 2016-04-17 02:55:29
对于这个术语的归档,您应该使用分类学模板。
对你来说,这将是taxonomy-project.php
当您使用自定义post类型时,您应该在更改模板时更新permalink结构,我的意思是注册新的post类型或创建新的模板文件。
https://wordpress.stackexchange.com/questions/223893
复制相似问题