Title: タグをカテゴリ別に絞り込みたい
Last modified: 2015年6月29日

---

# タグをカテゴリ別に絞り込みたい

 *  解決済 [bubbletmm](https://ja.wordpress.org/support/users/bubbletmm/)
 * (@bubbletmm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/)
 * 以下で生成されるリンクを　ランキングというタグをカテゴリ別に絞り込んだ結果が表示
   されるページへ遷移させたいのですが、どのように記述すればいいでしょうか？
 * <ul class=”arrow_box”>
    <?php $args = array( ‘title_li’ => ”, ‘orderby’ => ‘ID’,‘
   order’ => ‘ASC’, ‘echo’ => 0, // echoしない（文字列を返す） ); $list = wp_list_categories(
   $args); echo str_replace(‘/?’, ‘/?tag=ランキング&’, $list); ?>

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

 *  [gblsm](https://ja.wordpress.org/support/users/gblsm/)
 * (@gblsm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200123)
 * そういうページ遷移をするリンクを表示したい、ということですよね。その用途に wp_list_categories
   は向かないので、[get_categories](http://wpdocs.osdn.jp/関数リファレンス/get_categories)
   を使うのをおすすめします。
 * タグのスラッグが例えば ranking で、カテゴリーのIDを aaa（ここでは aaa と書きます
   が実際には数字です）とすると、「スラッグが ranking のタグをカテゴリ aaa に絞り
   込んだ結果が表示されるページ」のURLは `example.jp/?tag=ranking&cat=aaa` です。
   カテゴリーのIDを取得するのに get_categories が向いています。
 *  トピック投稿者 [bubbletmm](https://ja.wordpress.org/support/users/bubbletmm/)
 * (@bubbletmm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200129)
 * 回答ありがとうございます。
 * 続けざまで申し訳ありません。。パーマリンクに変更が加わり、example.jp/tag/ranking/
   となっているものをカテゴリで絞ったページに遷移するリンクを表示するためにはどの
   ように書いたらいいでしょうか？
 *  [gblsm](https://ja.wordpress.org/support/users/gblsm/)
 * (@gblsm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200160)
 * 絞りたいカテゴリーのIDを aaa とした場合、普通は example.jp/tag/ranking/?cat=aaa
   で大丈夫です。
 *     ```
       <a href="example.jp/tag/ranking/?cat=aaa">ランキングのカテゴリーaaa</a>
       ```
   
 * なお、カスタムパーマリンク設定を利用して example.jp/tag/ranking/ になるよう設定
   してあるなら、example.jp/?tag=ranking&cat=aaa を表示させると WordPress 自身が
   パーマリンクを example.jp/tag/ranking/?cat=aaa へ自動的に変換してくれると思い
   ます。（もしかすると example.jp/category/aaa?tag=ranking へ変換されるかもしれ
   ません。）
 *  トピック投稿者 [bubbletmm](https://ja.wordpress.org/support/users/bubbletmm/)
 * (@bubbletmm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200161)
 * ご返信ありがとうございます。
    たとえば、http://webdesignrecipes.com/さんのサイト
   で以下を試してみましたが、 miscのカテゴリの記事だけにはならず…。
 * [http://webdesignrecipes.com/tag/freelance/?cat=misc](http://webdesignrecipes.com/tag/freelance/?cat=misc)
 * しぼることは難しいのでしょうか？
 *  [gblsm](https://ja.wordpress.org/support/users/gblsm/)
 * (@gblsm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200162)
 * bubbletmmさん、`?cat=` の使い方を間違えていますよ。`cat=` に続けるのはカテゴリー
   の「ID」です（カテゴリーのスラッグは無視されます）。
 * 下記のリンクを試してください。`?cat=1` をつけないと投稿が 4 つ、つけると絞り込
   まれて一つになります。
 *     ```
       http://webdesignrecipes.com/tag/freelance/?cat=1
       ```
   
 * また、下記のリンクだとカテゴリーを選んでからタグで絞り込んだことになります。
 *     ```
       http://webdesignrecipes.com/category/webdesign/?tag=HTML5
       ```
   
 *  トピック投稿者 [bubbletmm](https://ja.wordpress.org/support/users/bubbletmm/)
 * (@bubbletmm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200184)
 * ご指摘の通りでした！
    以下のようにcategory.phpにかいており、?tag=XXXとしても絞り
   込まれません。。 どのように修正すれば宜しいでしょうか？何度もすみません。
 * <?php
    if (is_category()) { $this_cat = $cat; $query= ‘cat=’ . $this_cat . ‘&
   orderby=date&showposts=10’; query_posts($query); ?>
 * <h1><?php $cat = get_the_category(); ?>
    <?php $cat = $cat[0]; ?> <?php echo 
   get_cat_name($cat->term_id); ?>の新着記事</h1>
    - <?php while (have_posts()) : the_post(); ?>
       <li class=”clearfix”> “><?php
      the_post_thumbnail(‘thumbnail’); ?> <div> <h2>“> <?php the_title(); ?></h2
      > <?php if (wp_is_mobile()): ?> <p class=”excerpt”><?php echo mb_substr(get_the_excerpt(),
      0, 40); ?></p> <?php else: ?> <?php endif; ?> <p class=”sub”><span class=”
      cat”><?php the_category(‘, ‘); ?></span><span><?php if(function_exists(‘the_views’)){
      the_views();} ?></span></p> </div>
    - <?php endwhile; ?>
 * <?php } ?>
 *  トピック投稿者 [bubbletmm](https://ja.wordpress.org/support/users/bubbletmm/)
 * (@bubbletmm)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200192)
 * 以下に書き換えたらうまくいきました！
    ありがとうございました！！
 * <h1><?php the_category(‘, ‘); ?></h1>
    -  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       <li class
      =”clearfix”> “><?php the_post_thumbnail(‘thumbnail’); ?> <div> <h2>“> <?php
      the_title(); ?></h2> <?php if (wp_is_mobile()): ?> <p class=”excerpt”><?php
      echo mb_substr(get_the_excerpt(), 0, 40); ?></p> <?php else: ?> <p class=”
      lead”><?php the_excerpt(); ?></p> <?php endif; ?> <p class=”sub”><span class
      =”cat”><?php the_category(‘, ‘); ?></span><span><?php if(function_exists(‘
      the_views’)) {the_views();} ?></span></p> </div>
    - <?php endwhile; else: ?>
 * <?php endif; ?>

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

 トピック「タグをカテゴリ別に絞り込みたい」には新たに返信することはできません。

 * フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7件の返信
 * 2人の参加者
 * 最後の返信者: [bubbletmm](https://ja.wordpress.org/support/users/bubbletmm/)
 * 最後の活動: [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%bf%e3%82%b0%e3%82%92%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e5%88%a5%e3%81%ab%e7%b5%9e%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%9f%e3%81%84/#post-200192)
 * 状態: 解決済

## トピック

### 人気のトピック

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

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

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

### 未解決のトピック

### すべてのトピック
