投稿にコメントが存在する場合のみコンテンツを表示
if have_commentsで可能と思い込んでいたが、できなかったので代案。
1 2 3 4 5 | <?php if (get_comments_number()) { $ex_comments = 'コンテンツ'; } echo $ex_comments; ?> |
「コメントが2つ以上」など指定したいときは、
1 2 3 4 5 6 | <?php $num_comments = get_comments_number(); if ($num_comments >= 2) { $ex_comments = 'コンテンツ'; } echo $ex_comments; ?> |
コメントを投稿する