我创建了一个名为articles的自定义帖子类型,它将每月显示一篇文章。此自定义帖子具有层次结构(这意味着它还将包含与该月刊文章相关的子帖子)。
我的设置如下:
<?php
/* CUSTOM POST: MONTHLY ARTICLES */
add_action(\'init\',\'create_monthly_articles\');
function create_monthly_articles() {
$labels = array(
\'name\' => __(\'Articles\',\'mgr\'),
\'singular_name\' => __(\'article\',\'mgr\'),
\'add_new\' => _x( \'Add new article\', \'${4:Name}\', \'mgr\' ),
\'add_new_item\' => __( \'Add new article\', \'mgr\' ),
\'edit_item\' => __( \'Edit article\', \'mgr\' ),
\'new_item\' => __( \'New article\', \'mgr\' ),
\'view_item\' => __( \'View articles\', \'mgr\' ),
\'search_items\' => __( \'Search articles\', \'mgr\' ),
\'not_found\' => __( \'No articles found\', \'mgr\' ),
\'not_found_in_trash\' => __( \'No articles found in Trash\', \'mgr\' ),
\'parent_item_colon\' => __( \'Parent article name:\', \'mgr\' ),
\'menu_name\' => __( \'Articles\', \'mgr\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'description\' => __(\'A monthly article\',\'mgr\'),
\'taxonomies\' => array(\'category\'),
\'public\' => \'true\',
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => array(
\'with_front\' => false,
\'slug\' => \'articles\'
),
\'capability_type\' => \'post\',
\'supports\' => array(
\'title\', \'editor\', \'author\', \'thumbnail\',
\'custom-fields\', \'trackbacks\',
\'revisions\', \'page-attributes\',
),
);
register_post_type(\'cpt_article\',$args);
}
我想做的是,当我打电话的时候
http://myblog.com/articles/
会给我看最后一篇每月发表的文章
single-cpt_article.php
. 在该页面中,我附加了一个自定义帖子类型存档的链接,该链接将显示按月份排序的所有文章。
没有archive.php
/ archive-cpt_article.php
当我点击时,我可以看到我定制的文章页面http://myblog.com/articles/myarticle
但当我单击“归档”时,它会让我找到/文章/其中有一个通用类别。php页面,我需要为项目的其余部分。我怎样才能有一个介绍(主页)来显示该特定cpt的最新文章,以及一个存档页面来显示该特定cpt中的所有条目?
我试图实现的导航如下:
HOME -> ARTICLES -> SUB ARTICLES (Related to monthly article)
-> ARCHIVE PAGE (All top level articles sorted by month)