我有一个使用自定义分类法的自定义帖子类型。据我所知,它正在发挥作用,从某种意义上说,我可以创建一篇文章,并为其指定自定义分类术语。调试显示正在保存术语。
我想我的困惑在于模板层次结构是如何工作的。我复制了档案。php文件,并将其命名为“taxonomy-zouk\\u video\\u level.php”,现在正在调用它。但该文件中有通常的循环,当我导航到该术语的URL时,找不到帖子。
我应该使用不同的循环吗?还是我根本不使用循环?
这是我的自定义帖子类型代码:
<?php
function zouk_custom_types() {
$videolabels = array(
\'name\' => \'Videos\',
\'singular_name\' => \'Video\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Video\',
\'edit_item\' => \'Edit Video\',
\'new_item\' => \'New Video\',
\'all_items\' => \'All Videos\',
\'view_item\' => \'View Video\',
\'search_items\' => \'Search Videos\',
\'not_found\' => \'No Videos found\',
\'not_found_in_trash\' => \'No Videos found in Trash\',
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Videos\'
);
register_post_type( \'zouk_video\',
array(
\'labels\' => $videolabels,
\'description\' => __( \'A video.\', \'bonestheme\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_position\' => 1,
\'menu_icon\' => \'dashicons-editor-video\',
\'rewrite\' => array( \'slug\' => \'zouk_video\', \'with_front\' => false ),
\'has_archive\' => \'zouk_video\',
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\')
)
);
$instructorlabels = array(
\'name\' => \'Instructors\',
\'singular_name\' => \'Instructor\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Instructor\',
\'edit_item\' => \'Edit Instructor\',
\'new_item\' => \'New Instructor\',
\'all_items\' => \'All Instructors\',
\'view_item\' => \'View Instructor\',
\'search_items\' => \'Search Instructors\',
\'not_found\' => \'No Instructors found\',
\'not_found_in_trash\' => \'No Instructors found in Trash\',
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Instructors\'
);
register_post_type( \'zouk_instructor\',
array(
\'labels\' => $instructorlabels,
\'description\' => __( \'An instructor.\', \'bonestheme\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_position\' => 2,
\'menu_icon\' => \'dashicons-groups\',
\'rewrite\' => array( \'slug\' => \'zouk_instructor\', \'with_front\' => false ),
\'has_archive\' => \'zouk_instructor\',
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\')
)
);
/* use categories with the videos */
register_taxonomy_for_object_type( \'category\', \'zouk_video\' );
}
// adding the above to the Wordpress init
add_action( \'init\', \'zouk_custom_types\');
function zouk_video_types() {
// now custom term for video levels
register_taxonomy( \'zouk_video_level\', \'zouk_video\',
array(
\'hierarchical\' => true,
\'label\' => \'Video Levels\',
\'show_admin_column\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'video-level\' ),
\'public\' => true,
)
);
}
// adding the above to the Wordpress init
add_action( \'init\', \'zouk_video_types\');
?>