最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

remove custom taxonomy baseslug

programmeradmin2浏览0评论
This question already has answers here: Closed 12 years ago.

Possible Duplicate:
Remove slug in taxonomy url

I'm using proreview theme and it uses a custom taxonomy called "review-cats"

In of this

www.domain/review-cats/clothing

I want

www.domain/clothing

I've been trying to find a solution for 2 days not ...

relevant code

register_taxonomy(

"review-cats",

array("reviews"), array( "hierarchical" => false, "label" => "Categories", "singular_label" => "Category", "rewrite" => true ) );

This question already has answers here: Closed 12 years ago.

Possible Duplicate:
Remove slug in taxonomy url

I'm using proreview theme and it uses a custom taxonomy called "review-cats"

In of this

www.domain/review-cats/clothing

I want

www.domain/clothing

I've been trying to find a solution for 2 days not ...

relevant code

register_taxonomy(

"review-cats",

array("reviews"), array( "hierarchical" => false, "label" => "Categories", "singular_label" => "Category", "rewrite" => true ) );

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Apr 23, 2012 at 10:24 BramBram 111 silver badge2 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 1

This is not possible out of the box, nor is it advisable, and for good reason. If you really did want to do this you would need to hack the core files.

Why it's not a good idea:

  • WordPress does not check for Permalink clashes between taxonomy term slugs and page slugs
  • Say you have a page with the slug clothing, and a taxonomy term clothing, and you go to example/clothing ? Does the user want the page? Or the term? There's no way of telling!

Doing this is opening a can of worms for yourself.

Instead I recommend you use the rewrite parameter to redefine the slug as 'reviews'. Note that setting the slug to '' will not do what you desire, even though it seems like it should.

e.g.:

register_taxonomy(
    "review-cats",
    ["reviews"],
    [
        "hierarchical" => false,
        "label" => "Categories",
        "singular_label" => "Category",
        "rewrite" => [
            'slug' => 'reviews'
        ]
    ]
);

I also recommend you use a generator to create your taxonomy and post type code. Go here:

http://themergency/generators/

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论