• I want one div (#comments-area) to show up if a post has comments and another div(#no-comments-area) to show up when a post has no comments. How would I do this? Below is my failed attempt. I would really appreciate any help. Thanks.

    <?php if(has_comments()) {
    echo
    <div id="comments-area">
    <?php comments_template(); ?>
    </div>
    } else {
    echo
    <div id="no-comments-area">
    <?php comments_template(); ?>
    </div>
    }
    ?>

Viewing 1 replies (of 1 total)
  • Based on your code, it looks like there are a few syntax errors, as well as an improper mix of HTML and PHP. Try something like this:

    <?php if (has_comments()) { ?>
    <div id="comments-area">
    <?php comments_template(); ?>
    </div>
    <?php } else { ?>
    <div id="no-comments-area">
    <?php comments_template(); ?>
    </div>
    <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘<?php if (has_comments()) ?> ?’ is closed to new replies.