首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress将分类法/术语列表添加为存档页面中的菜单

Wordpress将分类法/术语列表添加为存档页面中的菜单
EN

WordPress Development用户
提问于 2016-04-16 22:18:07
回答 1查看 194关注 0票数 0

我在我的主题上创建了一个定制的post类型(deals)、术语(项目)、菜单(top_menu)和归档页面( archive actions.php)。我想在存档页面中显示术语帖子列表。但是,当我单击“术语”菜单时,然后重定向以下链接:http://localhost/wordpress/chorui/project/html-3/并显示错误消息页“找不到”。

代码语言:javascript
复制
<?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(); 
?>
EN

回答 1

WordPress Development用户

回答已采纳

发布于 2016-04-17 02:55:29

对于这个术语的归档,您应该使用分类学模板

对你来说,这将是taxonomy-project.php

当您使用自定义post类型时,您应该在更改模板时更新permalink结构,我的意思是注册新的post类型或创建新的模板文件。

票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/223893

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档