Title: 特定のカテゴリのコメントをサイドメニューに一覧表示する
Last modified: 2016年7月30日

---

# 特定のカテゴリのコメントをサイドメニューに一覧表示する

 *  [hazudog](https://ja.wordpress.org/support/users/hazudog/)
 * (@hazudog)
 * [14年、 1ヶ月前](https://ja.wordpress.org/support/topic/%e7%89%b9%e5%ae%9a%e3%81%ae%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%ae%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88%e3%82%92%e3%82%b5%e3%82%a4%e3%83%89%e3%83%a1%e3%83%8b%e3%83%a5%e3%83%bc%e3%81%ab%e4%b8%80/)
 * 特定のカテゴリのコメントをサイドメニューに一覧表示したく以下のコードを記述して
   おります。表示する項目はコメントに寄せられた、”お名前”、”日付”、”コメント本文”、”
   URL”を出力したいです。
 * ただ以下のコードですと、
    名前：日時　コメント　が出力されますが、最後にURLの
   項目が出力されません。 つまり、出力希望の項目は以下になります。 **名前：日時　
   コメント　URL**
 * `echo substr(get_comment_author_url(),7);`を以下のコードに織り込めば、URLも一覧
   項目に出力可能だと思われる？？のですが、当方phpの知識も非常に浅く、実現ができ
   ません。
 * 上記を実現できるコードをご教授いただけませんでしょうか。
    どうぞ宜しくお願い致
   します。
 *     ```
       <?php
       query_posts('category_name=battle');
       while (have_posts()) : the_post();
       $comments = $wpdb->get_results("SELECT *,SUBSTRING(comment_content,1,200) AS com_excerpt FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date DESC limit 10");
   
       $output = $pre_HTML;
       foreach ($comments as $comment) {
       //print_r($comment);
   
       $output .= "\n <div class='sanUsesr'><a href=\"" . get_permalink($comment->ID) .
       "#comment-" . $comment->comment_ID . "\" title=\"on " .
       $comment->post_title . "\"><b>".strip_tags($comment->comment_author)
       ."</b> : " . strip_tags($comment->comment_date_gmt)."</a></div>";
   
       $output .= "\n <p class='sancomments'>" . strip_tags($comment->com_excerpt)
       ."</p><br/><br/>";
       }
   
       $output .= $post_HTML;
       echo $output;
       endwhile;
       ?>
       ```
   
 * ちなみ特定のカテゴリのコメントを一覧表示するコードは以下のページを参考にしました。
   
   [http://www.w3cgallery.com/w3c-blog/wordpress-hack/wordpress-how-to-display-comments-from-specific-category](http://www.w3cgallery.com/w3c-blog/wordpress-hack/wordpress-how-to-display-comments-from-specific-category)
 * 宜しくお願い致します。

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

 *  [sz1320](https://ja.wordpress.org/support/users/sz1320/)
 * (@sz1320)
 * [14年前](https://ja.wordpress.org/support/topic/%e7%89%b9%e5%ae%9a%e3%81%ae%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%ae%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88%e3%82%92%e3%82%b5%e3%82%a4%e3%83%89%e3%83%a1%e3%83%8b%e3%83%a5%e3%83%bc%e3%81%ab%e4%b8%80/#post-151841)
 *     ```
       <?php
       query_posts('category_name=battle');
       while (have_posts()) : the_post();
       $comments = $wpdb->get_results("SELECT *,SUBSTRING(comment_content,1,200) AS com_excerpt FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date DESC limit 10");
   
       $output = $pre_HTML;
       foreach ($comments as $comment) {
       //print_r($comment);
   
       $output .= "\n <div class='sanUsesr'><a href=\"" . get_permalink($comment->ID) .
       "#comment-" . $comment->comment_ID . "\" title=\"on " .
       $comment->post_title . "\"><b>".strip_tags($comment->comment_author)
       ."</b> : " . strip_tags($comment->comment_date_gmt)."</a><span>" . strip_tags($comment-> comment_author_url)."</span></div>";
   
       $output .= "\n <p class='sancomments'>" . strip_tags($comment->com_excerpt)
       ."</p><br/><br/>";
       }
   
       $output .= $post_HTML;
       echo $output;
       endwhile;
       ?>
       ```
   
 * これどうですか？

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

 トピック「特定のカテゴリのコメントをサイドメニューに一覧表示する」には新たに返信
することはできません。

## タグ

 * [コメント サイドメニュー](https://ja.wordpress.org/support/topic-tag/%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88-%e3%82%b5%e3%82%a4%e3%83%89%e3%83%a1%e3%83%8b%e3%83%a5%e3%83%bc/)

 * フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1件の返信
 * 2人の参加者
 * 最後の返信者: [sz1320](https://ja.wordpress.org/support/users/sz1320/)
 * 最後の活動: [14年前](https://ja.wordpress.org/support/topic/%e7%89%b9%e5%ae%9a%e3%81%ae%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%ae%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88%e3%82%92%e3%82%b5%e3%82%a4%e3%83%89%e3%83%a1%e3%83%8b%e3%83%a5%e3%83%bc%e3%81%ab%e4%b8%80/#post-151841)
 * 状態: 未解決

## トピック

### 人気のトピック

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

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

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

### 未解決のトピック

### すべてのトピック
