是的,如果没有代码示例,我不确定自己能帮上多少忙,但我会给你我用来创建带有存档页的自定义帖子类型的代码。此示例将帮助您开始常见问题解答(易于修改)。
请注意重写行和刷新,这是为自定义Post类型创建永久链接结构的原因(并刷新缓存以激活它)。我怀疑这将使您非常接近您的期望,但如果不是,请提交您的代码,我将尽力提供帮助。
if ( ! function_exists( \'new_cpt_faq\' ) ) {
function new_cpt_faq() {
register_post_type( \'new_cpt_faq\',
array(
\'labels\' => array(
\'name\' => __( \'FAQs\', \'name_space\' ),
\'singular_name\' => __( \'FAQ\', \'name_space\' ),
\'add_new\' => __( \'Add New FAQ\', \'name_space\' ),
\'add_new_item\' => __( \'Add New FAQ\', \'name_space\' ),
\'edit_item\' => __( \'Edit FAQ\', \'name_space\' ),
\'new_item\' => __( \'New FAQ\', \'name_space\' ),
\'all_items\' => __( \'All FAQs\', \'name_space\' ),
\'view_item\' => __( \'View FAQ\', \'name_space\' ),
\'search_items\' => __( \'Search FAQs\', \'name_space\' ),
\'not_found\' => __( \'No FAQs found\', \'name_space\' ),
\'not_found_in_trash\' => __( \'No FAQs found in Trash\', \'name_space\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => __( \'FAQs\', \'name_space\' )
),
\'public\' => true,
\'has_archive\' => true,
\'supports\' => array( \'title\', \'editor\' ),
\'rewrite\' => array(
\'slug\'=>\'faqs\',
\'with_front\'=> false,
\'feed\'=> true,
\'pages\'=> true
)
)
);
flush_rewrite_rules();
}
}
add_action( \'init\', \'new_cpt_faq\' );
if ( ! function_exists( \'new_cpt_faq_taxonomy_categories\' ) ) {
function new_cpt_faq_taxonomy_categories() {
register_taxonomy(
\'new_cpt_faq\',
\'new_cpt_faq\',
array(
\'labels\' => array(
\'name\' => __( \'FAQ Category\', \'name_space\' ),
\'add_new_item\' => __( \'Add New FAQ Category\', \'name_space\' ),
\'new_item_name\' => __( \'New FAQ Category\', \'name_space\' )
),
\'show_ui\' => true,
\'show_tagcloud\' => true,
\'hierarchical\' => true
)
);
}
}
add_action( \'init\', \'new_cpt_faq_taxonomy_categories\' );
http://codex.wordpress.org/Function_Reference/register_post_type