Title: カテゴリー別記事　一覧ページを作成したい
Last modified: 2019年11月17日

---

# カテゴリー別記事　一覧ページを作成したい

 *  解決済 [pandora001](https://ja.wordpress.org/support/users/pandora001/)
 * (@pandora001)
 * [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/)
 * お世話になります。
 * 現在、カテゴリー別の記事一覧ページを作成しようとしているのですが、上手くいきま
   せん。
    ご教授いただけると幸いです。
 * 制作したいページは下記のような内容です。
 * ・カテゴリー別の記事一覧ページを作成
    ・カテゴリーは、カスタム投稿内でカテゴリー
   別に分かれている（親、子の2階層）
 * 現在下記の様にしてカテゴリー分けしようとしているのですが、上手くいきません。
 *     ```
       <main class="main
        bg_beige">
         <div class="index-newproperty__category">
           カテゴリ
           <a href="#" class="index-newproperty__categorybtn btn__rent">賃貸</a>
           <a href="#" class="index-newproperty__categorybtn btn__sale">売買</a>
         </div>
         <div class="index-newproperty__box">
         <?php
         $paged = (int) get_query_var('paged');
         $args = array(
           'posts_per_page' => 6,
           'paged' => $paged,
           'orderby' => 'post_date',
           'order' => 'DESC',
           'post_type' => 'property',
           'terms'=> 'sale',
           'post_status' => 'publish'
         );
   
         $the_query = new WP_Query($args);
         if ( $the_query->have_posts() ) :
           while ( $the_query->have_posts() ) : $the_query->the_post();
         ?>
         <?php
           $cat = get_the_category();
           $cat_slug  = $cat[0]->category_nicename;
         ?>
   
                     <article class="index-newproperty measures bg_white <?php echo $cat_slug ?>">
                       <a href="<?php the_permalink(); ?>">
                         <img class="news__article__img" src="<?php the_post_thumbnail_url(); ?>" height="250px">
                         <div class="index-property__content-text bg_white">
                           <h4 class=""><?php the_title(); ?></a></h4>
                           <time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('Y.m.d'); ?></time>
                           <p><?php the_excerpt('Read more'); ?></p>
                           <p class="index-property__content-more">MORE</p>
                         </div>
                       </a>
                     </article>
   
         <?php endwhile; endif; ?>
   
         <div class="pagination">
         <?php
         if ($the_query->max_num_pages > 1) {
           echo paginate_links(array(
             'base' => get_pagenum_link(1) . '%_%',
             'category_name' => 'rent',
             'format' => 'page/%#%/',
             'current' => max(1, $paged),
             'total' => $the_query->max_num_pages,
             'prev_text' => '',
             'next_text' => ''
           ));
         }
         ?>
         </div>
       ```
   
 * 現在の表示は、カスタム投稿内の記事一覧が出てしまい、希望する以外のカテゴリーの
   記事も出てしまっている状態です。
    一覧で表示したいカテゴリーのスラッグは、”sale”
   です。
 * 説明不足な部分もあると思いますが、お助けいただけると幸いです。
    よろしくお願い
   します。

5件の返信を表示中 - 1 - 5件目 (全5件中)

 *  [ishitaka](https://ja.wordpress.org/support/users/ishitaka/)
 * (@ishitaka)
 * [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/#post-11660491)
 * `'terms'=> 'sale',`
    ↓ `'category_name'=> 'sale',`
 * では、どうでしょうか？
 *  トピック投稿者 [pandora001](https://ja.wordpress.org/support/users/pandora001/)
 * (@pandora001)
 * [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/#post-11660495)
 * ishitaka (@ishitaka)様
 * ご連絡ありがとうございます。
    試してみたのですが、上手くいきませんでした。
 * 投稿一覧に記事が何も表示されなくなりました。
 * カスタム投稿の設定がおかしいのでしょうか⁇
    カスタム投稿の設定は下記の様になって
   おります。
 * functions.php
 *     ```
       function create_post_type_detail_property() {
         $Supports = [
           'title',
           'editor',
           'thumbnail',
         ];
         register_post_type( 'property',
           array(
             'label' => '物件',
             'labels' => array(
             'all_items' => '物件一覧'
             ),
             'public' => true,
             'has_archive' => true,
             'menu_position' => 5,
             'supports' => $Supports
           )
         );
           //カテゴリタイプの設定
         register_taxonomy(
           'property', //カテゴリー名（任意）
           'property', //カスタム投稿名
           array(
             'hierarchical' => true, //カテゴリータイプの指定
             'update_count_callback' => '_update_post_term_count',
             //ダッシュボードに表示させる名前
             'label' => '物件',
             'public' => true,
             'show_ui' => true
           )
         );
       }
       ```
   
 * なになら何までお聞きしてしまい申し訳ありません。
 *  トピック投稿者 [pandora001](https://ja.wordpress.org/support/users/pandora001/)
 * (@pandora001)
 * [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/#post-11660496)
 * 子カテゴリーは管理画面にて設定しました。
 * お手間おかけしますが、よろしくお願いします。
 *  [ishitaka](https://ja.wordpress.org/support/users/ishitaka/)
 * (@ishitaka)
 * [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/#post-11660518)
 * `'terms'=> 'sale',`
    ↓
 *     ```
       'tax_query' => array(
       	array(
       		'taxonomy' => 'property',
       		'field' => 'slug',
       		'terms' => 'sale',
       	),
       ),
       ```
   
 * では、どうでしょうか？
 *  トピック投稿者 [pandora001](https://ja.wordpress.org/support/users/pandora001/)
 * (@pandora001)
 * [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/#post-11660583)
 * ishitaka (@ishitaka)様
 * ありがとうございます。
    試しましたら、希望していた状態になりました。 本当にありがとう
   ございます。

5件の返信を表示中 - 1 - 5件目 (全5件中)

 トピック「カテゴリー別記事　一覧ページを作成したい」には新たに返信することはでき
ません。

## タグ

 * [一覧](https://ja.wordpress.org/support/topic-tag/%e4%b8%80%e8%a6%a7/)

 * フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5件の返信
 * 2人の参加者
 * 最後の返信者: [pandora001](https://ja.wordpress.org/support/users/pandora001/)
 * 最後の活動: [6年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%83%bc%e5%88%a5%e8%a8%98%e4%ba%8b%e3%80%80%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%9f%e3%81%84/#post-11660583)
 * 状態: 解決済

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
