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でカテゴリの説明を表示する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressサイトにカテゴリーの説明を表示したいですか?

カテゴリーを使えば、サイトのコンテンツを簡単に分類することができます。また、ユーザーが簡単にコンテンツを見つけることができ、SEO対策にもなります。

この投稿では、WordPressでカテゴリーに簡単に説明を追加する方法を紹介します。

How to Display Category Descriptions in WordPress

なぜWordPressでカテゴリー説明を表示するのか?

WordPressでサイトを作ったのであれば、すでにカテゴリーやタグを使っていることでしょう。しかし、それらをフルに活用しているとは限りません。

カテゴリーとタグを使えば、コンテンツをトピックごとに簡単に分類することができます。また、カテゴリーとタグを正しく使えば、WordPressのSEO対策にも役立ちます。

WordPressでは、カテゴリーに説明を追加することができます。投稿時にカテゴリーを作成する場合、説明を追加する権限がありませんので、このことに気づかないかもしれません。

ということで、WordPressでカテゴリーに簡単に説明を追加する方法を見てみましょう。

WordPressでカテゴリー説明を追加する

まず、投稿 ” カテゴリーページに移動する必要があります。新規カテゴリーを作成する場合は、ここでカテゴリー名と説明を入力し、「新規カテゴリーを追加」ボタンをクリックするだけです。

The Posts»Categories Page

既存のカテゴリーに説明を追加したい場合は、そのカテゴリーの下にある「編集」リンクをクリックする必要があります。

カテゴリー編集画面が表示され、カテゴリーの説明を追加することができます。

Add a Description to a Category

更新」ボタンをクリックして変更を保存することをお忘れなく。

この作業を繰り返すだけで、すべてのカテゴリーに説明が追加されます。同じ方法でタグにも説明を追加できます。

カテゴリーアーカイブページでのカテゴリー説明の表示

ほとんどのWordPressテーマは、カテゴリーアーカイブページにカテゴリーの説明を自動的に表示します。

Display Category Descriptions on Category Archive Pages

しかし、もしあなたのテーマがアーカイブページにカテゴリー説明を表示しないのであれば、テーマを修正する必要があります。最も安全な方法は、子テーマを作成することです。

詳しくは、初心者向けの子テーマの作成方法をご覧ください。

次に、親テーマから子テーマにファイルをコピーする必要があります。FTPクライアントまたはWordPressホスティングサービス会社が提供するcPanelファイルマネージャを使用することができます。

あなたのサイトの/wp-content/themes/parent-theme/フォルダーに行き、カテゴリー.phpファイルを見つける必要があります。もしあなたのファイルにそのファイルが含まれていなければ、代わりにアーカイブ.phpを見つける必要があります。

Find category.php or archive.php Using FTP Software

その後、子テーマのフォルダーにファイルをコピーしてください。

次に、ファイルを編集し、カテゴリー説明を表示したい場所に次のコード・スニペットを追加する必要がある:

<?php
the_archive_description( '<div class="taxonomy-description">', '</div>' );
?>

通常、これはthe_archive_titleを含むセクションの直後になります。コードを貼り付けたら、ファイルを保存するのを忘れないでください。

Paste the Code Snippet

カテゴリーアーカイブページにカテゴリーの説明が表示されるようになりました。

デモサイトの例です。Twenty Nineteenテーマは初期設定ではカテゴリー説明を表示しませんが、子テーマにコードスニペットを追加すると、カテゴリー説明が表示されるようになったことがわかります。

Preview of Category Description

WordPressテーマでカテゴリー説明を表示する

WordPressサイトでコードを使用することに慣れている場合は、これらのコードスニペットを使用して、サイト内の他の場所にカテゴリー説明を表示することができます。

サイトに個別カテゴリー説明を表示する

サイトの他の部分にカテゴリーの説明を表示したい場合は、category_descriptionテンプレートタグを使用する必要があります:

<?php echo category_description(3); ?>

3を使用したいカテゴリーのカテゴリーIDに置き換える必要がある。

カテゴリー説明の投稿表示について

個別投稿の中にカテゴリー説明を表示したい場合、例えばsingle.phpやfooter.phpテンプレートにコードスニペットを追加することができます。

子テーマを使用している場合は、まず親テーマのテンプレートを子テーマのフォルダーにコピーする必要があります。

その後、次のコードを追加する必要がある:

$catID = get_the_category();
echo category_description( $catID[0] );

このコードは、現在の投稿のすべてのカテゴリーを取得し、最初のカテゴリーのカテゴリー説明を出力するだけです。

すべてのカテゴリーと説明の一覧表示

WordPressのカテゴリーをすべてリスト形式で説明付きで表示したい場合は、テーマのfunctions.phpファイルにこのコードを追加するか、WPCodeプラグイン(推奨)を使用してコードスニペットを挿入します。

詳しくは、WordPressでカスタムコードを追加する方法をご覧ください。

function wpb_catlist_desc() {
$string = '<ul>';
$catlist = get_terms( 'category' );
if ( ! empty( $catlist ) ) {
  foreach ( $catlist as $key => $item ) {
    $string .= '<li>'. $item->name . '<br />';
    $string .= '<em>'. $item->description . '</em> </li>';
  }
}
$string .= '</ul>';

return $string;
}
add_shortcode('wpb_categories', 'wpb_catlist_desc');

このコードは、すべてのカテゴリーとその説明をプレーンなリストで表示するショートコードを作成します。

投稿とページで[wpb_categories]を使用できるようになりました。このショートコードをテキストウィジェット内で使用するには、ウィジェット用のショートコードを有効化する必要があります。

List WordPress categories with description

ボーナス:カテゴリのメタ情報を追加してSEOを改善する

初期設定では、WordPressはメタタグにカテゴリの説明を追加しません。

そのため、WordPressのSEOプラグインAll In One SEOfor WordPress」などを使ってカテゴリーメタ情報を追加し、SEOを強化することが重要です。

Adding a meta description for your category in All in One SEO

WordPressカテゴリーに関するエキスパートガイド

カテゴリの説明を表示する方法はお分かりいただけたと思いますが、WordPressのカテゴリに関連する他のガイドもご覧ください:

このチュートリアルで、WordPress でカテゴリの説明を表示する方法を学んでいただけたら幸いです。また、WordPress を HTTP から HTTPS に移行する方法や、サイトを成長させるために必要なプラグインを専門家が厳選したガイドもご覧ください。

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$編集プロセスをご覧ください。

Avatar

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

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

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

    • WPBeginner Support says

      To prevent that you would either need to create a site specific plugin or a child theme

      管理者

  2. Mirela says

    Hi. How do you make the description show only on the first page of the category? I want to avoid duplicate content :(

    • WPBeginner Support says

      Your SEO plugin should prevent duplicate content if you mean the description on the category archive

      管理者

    • WPBeginner Support says

      No, this would be for standard WordPress categories and not WooCommerce categories

      管理者

  3. Tiffany says

    So I created a category for slow cooker recipes. I titled it it “healthy slow cooler recipes”. It displays properly in the drop down menu and on the back end. But when I look at the category results page from the front end, it has extra words at the front of the title that I can’t find anywhere and I did not add them. I need to delete them but I’m not sure where this is pulling from. Any ideas?

    • WPBeginner Support says

      Your theme would likely be what’s adding it. If you reach out to your theme’s support they should be able to assist you.

      管理者

  4. Ola says

    God bless you real good. Please, how do I make the categories clickable? so that when someone clicks on each category, it will take them to the Archive list

  5. Anthony says

    Wondering if it’s possible to do this with custom post types. I have a recipe website and would love to add the descriptions to help with SEO.

    Thanks.

    • WPBeginner Support says

      As long as your custom post type accepts categories it should be able to display the same way.

      管理者

  6. Sandra says

    Hi,
    Is there a way to hide the description of the categories? I am looking for the opposite of this post (Hide Category Descriptions) but can’t seem to find anything :(

    My previous theme didn’t display category descriptions, but I updated today to wpocean and this new theme does display the text, I don’t like it. I feel that users will get lost or won’t scroll down to read the posts :/

    Is there a code to fix it?

    • WPBeginner Support says

      You would want to reach out to the support for your current theme first to see if there is an option to do so built-in with the theme or a recommended method to remove the description.

      管理者

  7. Mads Grønlund says

    EDIT: I am now subscriting to replies. You can delete my other reply. :-)

    Hey! Great post, although I would like to ask, is there a way to move the category description to the bottom of the page? In case I want say a 2.000 words description for the SEO-value but I don’t want it to block all the actual posts in that category.

    Thanks in advance!

    • WPBeginner Support says

      Hi Mads Grønlund,

      Yes, you can do that. For that you will need to edit your theme template files like category.php. Look for the code responsible for displaying description and move it down towards the end of the loop. You may run across some issues, so it would be best to backup your original template files first.

      管理者

  8. Dejan says

    Hello everyone,

    This is very useful post and I was cracking my head why the category description wasn’t being displayed in my theme, and following this tutorial it occured to me that my theme didn’t even have the category.php or archive.php files!
    In such cases you need to edit the index.php file with the code provided in this tutorial. It worked like a charm for me :)

    • D says

      I don’t have category or archive in my theme either. Tried posting code in index.php but didn’t work (and i have no clue what I’m doing to post the code there) any way you can elaborate on the steps a little more?

  9. Madison Woods says

    Is there a way to make the category description only show up on the first page of category archives? Isn’t it ‘duplicate content’ if it appears on every page of that category’s posts? Some of my categories contain a large amount of posts so there might be 4 or 5 pages of ‘older posts’ in that category. Each one of those pages of posts shows the same description. Thanks for any tips!

  10. Naomi says

    Thanks so much for this tip – it worked absolutely perfectly and it saved me a lot of potential headaches.

    My category description is showing up as planned, just where I wanted it to :)

  11. Beth says

    If my category is a subcategory I notice there are two description boxes to fill out. Only the bottom one will automatically show up on my subcategory page. Should I fill out both description boxes? Should they be the same?

返信を残す

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