我发现这个地方在过去是一个很好的信息来源,通过大量的谷歌搜索我遇到的问题。我的问题与WordPress使用的详细重写规则有关。
我已经设置了一个名为“project”的自定义帖子类型,并注册了一个名为“project”的自定义分类法。除了重写段塞选项外,其他一切都很好,因为它们最终会发生冲突,很可能是因为重写规则。
基本上,这就是我希望实现的结构:
example.com/work/%taxonomy%/%post_name%/
(对于帖子)example.com/work/%taxonomy%/
(列出属于特定词汇的帖子)example.com/work/
(转到page-work.php,其中包括taxonomy.php,列出与该分类法相关的所有帖子)
$labels = array(
\'name\' => _x(\'Projects\', \'post type general name\'),
\'singular_name\' => _x(\'Project\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'project item\'),
\'add_new_item\' => __(\'Add New Project\'),
\'edit_item\' => __(\'Edit Project\'),
\'new_item\' => __(\'New Project\'),
\'view_item\' => __(\'View Project\'),
\'search_items\' => __(\'Search Projects\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'hierarchical\' => true,
\'rewrite\' => array(\'slug\'=>\'work\', \'with_front\'=>false),
\'show_ui\' => true,
\'_builtin\' => false, // It\'s a custom post type, not built in!
\'capability_type\' => \'post\',
\'query_var\' => "project", // This goes to the WP_Query schema
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\',\'thumbnail\', \'comments\', \'author\', \'excerpt\')
);
register_post_type(\'project\' , $args);
// Showcase Taxonomy
register_taxonomy(\'projects\', array(\'project\'), array(
\'public\' => true,
\'hierarchical\' => true,
\'label\' => \'Project Categories\',
\'singular_label\' => \'Project Category\',
\'query_var\' => true,
\'rewrite\' => array(\'slug\'=>\'work\', \'with_front\'=>false, \'hierarchical\'=>true)
)
);
非常感谢您的帮助!:-)