我最近发现我可以使用with-front=>false
中的参数register_post_type()
. 所以我去修改了我的自定义post-type Slug并做了一个flush_rewrite_rules()
. 现在,我的自定义帖子类型中有2个使用了所需的URL,2个没有使用。工作的2与其他2之间的唯一区别是,它们还具有自定义分类法。这是我的functions.php
文件知道我做错了什么吗?
add_action(\'init\',\'ASH_addtaxonomies\');
add_action(\'init\',\'ASH_addposttypes\');
function ASH_addtaxonomies(){
register_taxonomy(\'ash_weave_structure\', null,
array(\'labels\'=>array(\'name\'=>\'Weave Structures\',
\'singular_name\'=>\'Structure\'),
\'public\'=>true,
\'hierarchical\'=>true,
\'rewrite\'=>array(\'slug\'=>\'samples_weaving/structures\', \'with-front\'=>false),
\'query_var\'=>true
)
);
register_taxonomy(\'ash_weave_technique\', null,
array( \'labels\'=>array( \'name\'=>\'Weaving Techniques\',
\'singular_name\'=>\'Technique\'),
\'public\'=>true,
\'hierarchical\'=>false,
\'rewrite\'=>array(\'slug\'=>\'samples_weaving/techniques\', \'with-front\'=>false),
\'query_var\'=>true
)
);
register_taxonomy(\'ash_equip_cats\', \'ash_equipment\',
array( \'labels\'=>array( \'name\'=>\'Equipment Categories\',
\'singular_name\'=>\'Equipment Category\'),
\'public\'=>true,
\'hierarchical\'=>true,
\'show_ui\'=>true,
\'show_in_nav_menus\'=>true,
\'rewrite\'=>array(\'slug\'=>\'equipment/category\', \'with_front\'=>false),
\'query_var\'=>true
)
);
}
function ASH_addposttypes(){
//good archive url: http://example.com/samples_weaving/
register_post_type(\'ash_weaving\',
array(
\'description\' => \'Picture, draft and technical details of a weaving sample\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\'=>5,
\'rewrite\'=>array(\'slug\'=>\'samples_weaving\', \'with_front\'=>false),
\'query_var\' => true,
\'taxonomies\'=>array(\'post_tag\',\'ash_weave_structure\',\'ash_weave_technique\'),
\'has_archive\'=>true,
\'supports\' => array( \'title\',
\'editor\',
\'excerpt\',
\'comments\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\'),
\'labels\' => array ( \'name\'=>__(\'Weaving Samples\'),
\'singular_name\'=>__(\'Weaving Sample\')
)
)
);
//bad archive url: http://example.com/archives/samples_spinning/
register_post_type(\'ash_spinning\',
array(
\'description\' => \'Picture and technical details of a spinning sample\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\'=>5,
\'rewrite\'=>array(\'slug\'=>\'samples_spinning\', \'with-front\'=>false),
\'query_var\' => true,
\'taxonomies\'=>array(\'post_tag\'),
\'has_archive\'=>true,
\'supports\' => array( \'title\',
\'editor\',
\'excerpt\',
\'comments\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\'),
\'labels\' => array ( \'name\'=>__(\'Spinning Samples\'),
\'singular_name\'=>__(\'Spinning Sample\')
)
)
);
//bad archive url: http://example.com/archives/samples_dyeing/
register_post_type(\'ash_dyeing\',
array(
\'description\' => \'Picture and technical details of a dyeing sample\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\'=>5,
\'rewrite\'=>array(\'slug\'=>\'samples_dyeing\',\'with-front\'=>false),
\'query_var\' => true,
\'taxonomies\'=>array(\'post_tag\'),
\'has_archive\'=>true,
\'supports\' => array( \'title\',
\'editor\',
\'excerpt\',
\'comments\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\'),
\'labels\' => array ( \'name\'=>__(\'Dyeing Samples\'),
\'singular_name\'=>__(\'Dyeing Sample\')
)
)
);
//good archive url: http://example.com/equipment/
register_post_type(\'ash_equipment\',
array(
\'description\' => \'Weaving and spinning equipment that ASH makes available to members\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\'=>5,
\'rewrite\'=>array(\'slug\'=>\'equipment\',\'with_front\'=>false),
\'query_var\' => true,
\'taxonomies\'=>array(\'post_tag\',\'ash_equip_cats\'),
\'has_archive\'=>true,
\'supports\' => array( \'title\',
\'excerpt\',
\'thumbnail\',
\'page-attributes\'),
\'labels\' => array ( \'name\'=>__(\'Equipment\'),
\'singular_name\'=>__(\'Equipment\')
)
)
);
}