Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressのURLにカテゴリーとサブカテゴリーを含める方法

WordPressのSEOガイドの多くは、シンプルなパーマリンクがベストだと述べています。しかし、多くのサイトを見てきた結果、必ずしもそうではないことがわかりました。

特に大きなサイトでは、「yourstore.com/electronics/smartphones/iphone」のように、どこにいるのかがわかるようなURLにしたほうがいい場合もあります。このように明確な構造にすることで、サイトを使いやすくすることができます。

WordPressを初めてお使いになる方は、このようなパーマリンク構造を自分のサイトにどのように設定すればよいのか迷うかもしれません。このガイドでは、URLにカテゴリーとサブカテゴリーを追加する方法を紹介します。なぜこのような設定が必要なのか、安全に行うにはどうすればよいのか、何に気をつければよいのかについて説明します。

How to Include Category and Subcategory in WordPress URLs

WordPressのURLにカテゴリーとサブカテゴリーを含めるタイミング

WordPressサイトの中には、サイトに多くのコンテンツがあり、それらをよりよく整理したい場合に、URLにカテゴリーやサブカテゴリーを使用するものがあります。WPBeginnerでは、読者がサイトをナビゲートしやすくするために、この戦略を使っています。

例えば、こうだ:

https://www.wpbeginner.com/plugins/7-best-wordpress-backup-plugins-compared-pros-and-cons/

オンラインショップでは、URLにカテゴリーやサブカテゴリーを含めることで、ユーザーがアクセスしようとしているコンテンツを視覚的に示すことができ、ユーザーエクスペリエンスを向上させることができます。

例えば、onlinestore.com/books/fiction/thrillerのようなURLは、ユーザーがWordPressサイトのより広いカテゴリー内の特定のサブカテゴリーに移動していることを示します。

URLにカテゴリーやサブカテゴリーを含めることは、検索エンジンがサイトの構造を理解するのにも役立ちます。URLはサイト上のパンくずリストナビゲーションと一致し、より多くのキーワードとテキストを含み、あなたのサイトをよりSEOフレンドリーにしてくれます。

カテゴリーについて詳しくは、WordPressのタクソノミーと カテゴリー vs タグ:コンテンツを分類するためのSEOベストプラクティスに関するガイドをご覧ください。

WordPressの初期設定のURL構造を使用している場合、カテゴリーとサブカテゴリーは投稿URLに含まれません。そこで、WordPressのURLにカテゴリーとサブカテゴリーを簡単に追加する方法を見てみましょう。

WordPressの投稿URLにカテゴリーとサブカテゴリーを簡単に追加する方法

注: WordPressサイトが公開されてからしばらく(つまり6ヶ月以上)経過している場合は、パーマリンクを変更することをお勧めしません。そうしないと、検索エンジンの順位が下がる可能性があります。

パーマリンク構造を変更しなければならない場合は、エラーに備えてサイトをバックアップし、古いURLから新しいURLへのリダイレクトを作成することをお勧めします。

まず、WordPress管理ダッシュボードの設定 ” パーマリンクのページにアクセスする必要があります。そこで、共通設定エリアの「カスタム構造」オプションをクリックする必要があります。

Adding category to WordPress post URLs

次に、カスタム構造の隣のフィールドに/%category%/%postname%/を追加する必要があります。

その後、「変更を保存」ボタンをクリックし、カスタマイリンクの設定を保存することを忘れないでください。

それだけだ!

Save permalinks settings

WordPressのURLにカテゴリーと子カテゴリーが追加されます。カスタムパーマリンクの設定は、新しい投稿を作成するか、既存の投稿を編集することで確認できます。

サイドバーで投稿にカテゴリー(サブカテゴリーを使用している場合はサブカテゴリーも)を割り当て、「更新」ボタンをクリックするだけです。

WordPress URL with category and subcategory

投稿のパーマリンクにカテゴリー名とサブカテゴリー名が含まれていることがわかります。

複数のカテゴリーやサブカテゴリーを使用する場合、URLはどのようになりますか?

WordPressブログの投稿を複数のカテゴリーやサブカテゴリーに分類するとしよう。

WordPressは、1つのカテゴリーと1つの子カテゴリーだけをURLに含めます。サブカテゴリーを選択しなかった場合は、1つの親カテゴリーのみが表示されます。

WordPressはカテゴリーをアルファベット順に選択します。例えば、「Apple」と「Technology」カテゴリーを使って投稿した場合、WordPressは「apple」をURLに含めます:

http://example.com/apple/article-title-here/

アップル」に投稿し、その下に「テクノロジー」というサブカテゴリーを作れば、URLにはその両方が含まれます:

https://example.com/apple/technology/article-title-here/

サブカテゴリーを選択したが、親カテゴリーを特に選択しなかった場合でも、WordPressはURLに親カテゴリーを含めます。

もう一つのシナリオは、親カテゴリー、サブカテゴリー、サブサブカテゴリーがある場合です。WordPressはこれら3つすべてをWordPressパーマリンクに含めます:

https://example.com/apple/technology/events/article-title-here/

パーマリンクについて詳しくは、以下のWordPressガイドをご覧ください:

WordPressのURLにカテゴリーとサブカテゴリーを含める方法について、この投稿がお役に立てば幸いです。WordPressでカテゴリのベースプレフィックスを変更する方法の投稿や、WordPressでカスタマタクソノミーを作成するための初心者ガイドも参考にしてください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

55件のコメント返信を残す

  1. AB Juma

    Hi there,

    Thank you for this. Very helpful.

    Just a question – I already have more than 2,000 posts on my website with the day and name url structure. If I change to custom, will those urls change too, or does the change only apply to new posts? Thanks.

  2. Jay

    it’s only putting the Parent cateogry in the slug.
    How can i make it automatically put subcategory in the url as well?

    • WPBeginner Support

      Please check that the post is only in the subcategory for the most likely reason for that issue.

      管理者

  3. Brendon

    This seems to break any products that do not use a sub category at all.

  4. Taoheed

    I would be glad if you answer this. Let’s assume i published a post into two/three categories or sub-categories, wouldn’t it be treated as duplicate content on google?

    • WPBeginner Support

      It should not cause Google to see it as duplicate content but if you have posts that are in multiple categories then your users would see that same post when they viewed your other categories. We would normally recommend only one category for a post.

      管理者

  5. David

    Please is there a way to include tags in the URL instead of categories?

    • WPBeginner Support

      We do not have a recommended method for including tags in your URL at the moment, we would recommend taking a look at our article below that covers the organizational differences between the two for why categories are preferred over tags in permalinks:
      wpbeginner.com/beginners-guide/categories-vs-tags-seo-best-practices-which-one-is-better/

      管理者

  6. Phu Nguyen

    Hi,

    Currently I have a url: abc.com/games/ff9/weapon-list/

    and I can’t create another post with the same name (weapon-list) on another category.

    It will be like abc.com/games/ffx/weapon-list-1/

    Is there any solution for my case? Looking forward to your help

    • WPBeginner Support

      The end of the URL would be determined by your post’s name and the other sections would be determined by your permalink structure. You cannot have the same name for the time being and would need a different name

      管理者

  7. Lori S.

    So for pages, it would just skip over the /%category%/ and maintain the original post name?

    • WPBeginner Support

      Yes :)

      管理者

  8. Ashish

    Is it a disadvantage to using categories in URL? like example.com/plugin/best-plugin/. in this case plugin uses 2 times. is this URL looks spammy?

    • WPBeginner Support

      You would want to try avoiding looking spammy with your choice of title but it is not a disadvantage to use categories n your URL.

      管理者

  9. jacques

    Important note: To get URL structure like: /category/child1/child2/POSTNAME then ONLY select “child2” as the post category when editing the post. Wordpress will automatically add all parent categories to the URL. Took me a while to figure that out.

    • WPBeginner Support

      Thanks for sharing this for people looking for that permalink setup :)

      管理者

    • Austin Epple

      You’re the man. I’ve been tearing my hair out trying to get these stupid subcategories in the url. Thank you!

    • Smart

      Thank you so much @jacques, you just helped me solve a challenge that has taking me so many hours without solution. Thanks mahn

  10. Rubb

    How this work with pages? pages don’t use categories

    • WPBeginner Support

      As they do not have categories, they would not have the category in the URL

      管理者

  11. Ben

    So how do i redirect from /%postname%/ to /%category%/%postname without the redirection plugin.

  12. May

    Is there a way to add hierarchy to parent categories? If a post has two categories how can I chose which category is used in the URL.

    As you say in your article, default is alphabetical.

    For example I have a post categorised “Fruit” and “Vegetable” with the permalink set to show /%category%/%postname%/.

    The URL shows website.com/Fruit/postname but I want it to use website.com/vegetable/postname.

    • WPBeginner Support

      In those situations, you may want to look into how your categories are organized to see if tags may be what you need more than categories for some organizations. Normally posts shouldn’t be in multiple categories.

      管理者

  13. Nik

    How can I add category in my page url.

    • WPBeginner Support

      By default, pages don’t have categories so they wouldn’t be included in the page options.

      管理者

  14. Mlimasolucoes

    Use subcategory as primary category then URL will work

    • WPBeginner Support

      Thank you for sharing that recommendation :)

      管理者

    • Muhammad Kashif Rasheed

      You answer is valuable for me, because I read all the post but not permalink not work fine on my side, when I applied your suggestion I got answer of my question.
      Once again thankyou very much,

  15. Sravankumar

    I am unable to see subcategory in any posts.

    I am facing issue while creating a post name. How can Icreate a URL like this: site/destinations/europe/norway/post-name

    I have the page to create a URL like above is it only possible if I create a page or with post name also can we create?

    site/destinations/europe/norway/

    • WPBeginner Support

      If I’m understanding the question correctly, you don’t need to create a page at the second link’s location as that would be your subcategory’s page listing the posts in that subcategory.

      管理者

  16. Nancy

    Can i Include Category and Subcategory in post URLs without using permalink

  17. V

    Adding /%category%/%postname%/ to the permalink structure breaks the pagination for some reason. Anyone else facing this?

    • WPBeginner Support

      There are multiple possible reasons pagination could not be working, you may want to check with your specific theme’s support or reach out to us using our contact form for which would likely fix the issue.

      管理者

  18. jesica

    How did you do to link your subcategory menu pages to a clean url: YOURSITE.COM/SUBCATEGORY? without the YOURSITE.COM/CATEGORY/SUBCATEGORY?
    I don’t know how to delete the parent category from the subcategory URL on my site…

    • WPBeginner Support

      We don’t have a simple recommended method at the moment. If you want to remove reference to the parent category, should that category be a child category?

      管理者

  19. Shubham Dixit

    I have an issue. I am using Custom Structure to display category name before the post name ( /%category%/%postname%/ ). It is working fine when I am logged in but after log out It doesn’t display category name in url.

    The above issue in in chorme browser. In firefox it is working fine.

    Please help!

  20. Ted

    Yeah.. we all know this information.. you see %category% and it is obvious what it does. But Thanks….
    WHAT I WAS LOOKING FOR is code as in rewrite rules for my themes functions file..

  21. jcdarocha

    Hi !
    Trick works well for a blog post / category.
    but what about woocommerce ? ay idea ?
    Even when you add this in permalink structure, WC show the main-category/product-name even if there 2 or 3 sub categories
    This is really annoying,
    Any idea?
    Thank you
    Jean-Charles

    • Paul

      Got the same question. Why is that not possible for Woocommerce?!
      Any help is appreciated!

  22. Simon

    This is great, but how would I go about having multiple URLs for the same post with multiple categories? So if I go from 1 category the URL is for that category and if I go from another it is that category?

    Thanks

  23. Jordan

    Won’t this cause duplication problems? How do you make it so the parent category doesn’t open to an archive page?

    Like as an example – Main topic Music and then have a subcategory called popmusic…..

    Music ( Not Clickable )
    Pop Music ( Clickable and rediects to your posts associated with that sub categories)

    My issue with this is people clicking the parent categories and getting redirected to a page with no post associated with it because you don’t want to have duplicate content or a post in music & pop music

  24. Yash chandra verma

    So what will be url if two different parent category are used. Please tell me?

  25. Vale

    Why Woocommerce do not support Subcaregories in permalinks?
    Google and other browsers recommed clean URL’s. And woocommerce Category slug can not be removed unless you pay $119 Usd for a plugin that does the trick.
    Is there another way to achieve these two issues?

  26. Jose

    Thanks for this post. Its working for me. The only thing doesn`t work is when i try to list news by a subcategory

    Eg. mydomain.com/categorybase/subcategory/nameofnew/

    this works showing me the blog post, but if i want to list all posts of this subcategory like this

    mydomain.com/categorybase/subcategory/

    does’nt work.

    Any ideas how to fix it?

    Thanks in advance.

  27. Denish Callos

    HI,
    I have added categories and tags in my pages. Now how do i add categories in pages permalink?
    Please suggestion will be highly appreciated.
    Thanks

  28. Kahil

    This solution ONLY works if you select the subcategory in the post/page category list. If you have both the parent and the subcategories checked, then the parent category is the only one that shows. For those of us using Woocommerce, this messes with the related products. If you select just the subcategory, then you won’t see any related items from the parent category. If you select them both, then you’re back to dealing with not having the subcategory listed in your URL. Been looking for a simple solution to cover both needs.

    • Paul

      Have you found a solution? We have the same exact problem right now. This is quite annoying and we don’t know what to do about it.
      Any ideas or solutions are appreciated!

  29. regel

    Hi don’t have “permalink” on my setting. Any option?

  30. Giulia Sampogna

    Hello,
    that´s a really nice post. I am wondering if I change it now will change my past one as well? If yes I would had to redirect all links right?

    Thanks a lot

  31. Dan

    I’m confused and could use some help.

    Specifically, I am developing an ecommerce site that is composed of mostly PAGES. (NOT using woocommerce or another e-commerce platform, but building out my own gravity form for each product page).

    I want the product category to be in ALL my PAGE URL’s, but as you know, wordpress out of the box doesn’t enable assignment of categories and tags to PAGES (wish it did). One alternative would be to use one of the plugins I found that could enable this. The other is to simply use the product category name in the SLUG (part of the permalink I can create on the product page). I could also create a page for each product category and include a gallery showing each product item that belongs to that category with a link to its specific page, or, I could skip the product category page altogether and assign the “#” in front of the category name when I create the menu, so that the category name would appear but not be an active link to any category page. I could get involved in creating a “custom post type” for my product pages which would enable them to be assigned a category and tag, much like the woocommerce product “pages” are setup (don’t know much about how to do that but would like to), etc.

    Also, the permalink settings effect URL’s for both pages and posts…correct ?

    REALLY appreciate a followup post from you that deep dives into helping people like me who are using wordpress for their ecommerce site but not using one of the out of the box ecommerce platforms.

    thankyou

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。