Forums

How to get whether comments are enabled or not (4 posts)

  1. finkyfeke
    Member
    Posted 1 year ago #

    Hi,
    I have a little notification of how many comments there are on each post.

    <small class="comments">
    <?php comments_number('No comments','1 comment','% comments'); ?>
    </small>

    The problem is that I don't want this to show if comments are disabled for a post.
    Is there a function in wp that allows you to determine whether comments are enabled or not?
    Thanks,
    Richard

  2. finkyfeke
    Member
    Posted 1 year ago #

    ...anybody...?

  3. mikey1
    Member
    Posted 1 year ago #

    Hi, look at settings, general, under membership.
    mike.

  4. finkyfeke
    Member
    Posted 1 year ago #

    I want to be able to get whether comments are disabled or not as a true/false variable to use in php. So I can do something like this:

    <?php if(comments_enabled()) { ?>
       <small class="comments">
       <?php comments_number('No comments','1 comment','% comments'); ?>
       </small>
    <?php } ?>

    ...where 'comments_enabled()' returns a boolean value based on whether this particular post has comments enabled.
    But 'comments_enabled' isn't a function. I need something to replace it with that will return the value I'm looking for.

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags