首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自定义post归档URL错误

自定义post归档URL错误
EN

WordPress Development用户
提问于 2012-02-07 18:07:41
回答 1查看 72关注 0票数 0

最近我发现我可以在with-front=>false中使用register_post_type()参数。因此,我去改变了我的自定义post类型的子弹,并做了一个flush_rewrite_rules()。现在,我的2个自定义post类型正在使用所需的URL,而2个则不使用。唯一的区别是,工作的2和其他,是他们也有自定义分类法。这是我的functions.php文件中的代码。知道我做错什么了吗?

代码语言:javascript
复制
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')
                                              )
                        )
        );
}
EN

回答 1

WordPress Development用户

回答已采纳

发布于 2012-02-07 19:17:56

问题是在寄存器函数中,在rewrite中,您必须将with-front更改为with_front

票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/41531

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档