Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    This Conditional Tag checks if comments are allowed for the current Post being processed in the WordPress Loop. This is a boolean function, meaning it returns either TRUE or FALSE.

    Yes, it is ?? Can’t tell you status on a page if you don’t say which page. But if it’s used on a post, I think that gets passed through.

    Thread Starter h-u-g-o

    (@h-u-g-o)

    Thanks for your answer.

    In the comments.php of Twenty Eleven for example, the function is called without any parameters.

    <?php
        /* If there are no comments and comments are closed, let's leave a little note, shall we?
         * But we don't want the note on pages or post types that do not support comments.
         */
        elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
    ?>
        <p class="nocomments"><?php _e( 'Comments are closed.', 'twentyeleven' ); ?></p>
    <?php endif; ?>
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Because it’s included in the single.php template file and called, specifically, FROM that post. If you tried to just show the comments of any post on a separate page (i.e. NOT the post page) you would need to specify the post ID.

    Thread Starter h-u-g-o

    (@h-u-g-o)

    Thanks again for your answer.

    Alright, but in certain circumstances the parameter is optional. In my opinion, that should be made clear in the Codex.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    No, because it’s still required. The twenty ten theme is passing that data through, even though you can’t see it.

    Think of it this way ‘None = the page I’m on.’

    Thread Starter h-u-g-o

    (@h-u-g-o)

    Well, I actually understand, what you’re saying. But comments_open() is a function call without parameters. You agree with that, don’t you?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Kind of ??

    Yes it’s a function call without any inserted parameters, so it DEFAULTS to comments_open(none), which means ‘This page’ ?? If there’s no value, it puts one in for you.

    Thread Starter h-u-g-o

    (@h-u-g-o)

    Anyway, thank you very much for your patience. ??

    Have a good day, evening or night, wherever you are.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WordPress Codex: Function Reference/comments open’ is closed to new replies.