comments_number

The timeline below displays how wordpress function comments_number has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Displays the language string for the number of comments the current post has.
 *
 * @since 0.71
 * @since 5.4.0 The `$deprecated` parameter was changed to `$post`.
 *
 * @param string|false $zero Optional. Text for no comments. Default false.
 * @param string|false $one  Optional. Text for one comment. Default false.
 * @param string|false $more Optional. Text for more than one comment. Default false.
 * @param int|WP_Post  $post Optional. Post ID or WP_Post object. Default is the global `$post`.
 */
function comments_number($zero = false, $one = false, $more = false, $post = 0)
{
    echo get_comments_number_text($zero, $one, $more, $post);
}

WordPress Version: 5.7

/**
 * Displays the language string for the number of comments the current post has.
 *
 * @since 0.71
 * @since 5.4.0 The `$deprecated` parameter was changed to `$post_id`.
 *
 * @param string|false $zero    Optional. Text for no comments. Default false.
 * @param string|false $one     Optional. Text for one comment. Default false.
 * @param string|false $more    Optional. Text for more than one comment. Default false.
 * @param int|WP_Post  $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
 */
function comments_number($zero = false, $one = false, $more = false, $post_id = 0)
{
    echo get_comments_number_text($zero, $one, $more, $post_id);
}

WordPress Version: 5.4

/**
 * Displays the language string for the number of comments the current post has.
 *
 * @since 0.71
 * @since 5.4.0 The `$deprecated` parameter was changed to `$post_id`.
 *
 * @param string      $zero       Optional. Text for no comments. Default false.
 * @param string      $one        Optional. Text for one comment. Default false.
 * @param string      $more       Optional. Text for more than one comment. Default false.
 * @param int|WP_Post $post_id    Optional. Post ID or WP_Post object. Default is the global `$post`.
 */
function comments_number($zero = false, $one = false, $more = false, $post_id = 0)
{
    echo get_comments_number_text($zero, $one, $more, $post_id);
}

WordPress Version: 4.6

/**
 * Display the language string for the number of comments the current post has.
 *
 * @since 0.71
 *
 * @param string $zero       Optional. Text for no comments. Default false.
 * @param string $one        Optional. Text for one comment. Default false.
 * @param string $more       Optional. Text for more than one comment. Default false.
 * @param string $deprecated Not used.
 */
function comments_number($zero = false, $one = false, $more = false, $deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '1.3.0');
    }
    echo get_comments_number_text($zero, $one, $more);
}

WordPress Version: 4.0

/**
 * Display the language string for the number of comments the current post has.
 *
 * @since 0.71
 *
 * @param string $zero       Optional. Text for no comments. Default false.
 * @param string $one        Optional. Text for one comment. Default false.
 * @param string $more       Optional. Text for more than one comment. Default false.
 * @param string $deprecated Not used.
 */
function comments_number($zero = false, $one = false, $more = false, $deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '1.3');
    }
    echo get_comments_number_text($zero, $one, $more);
}

WordPress Version: 3.9

/**
 * Display the language string for the number of comments the current post has.
 *
 * @since 0.71
 *
 * @param string $zero       Optional. Text for no comments. Default false.
 * @param string $one        Optional. Text for one comment. Default false.
 * @param string $more       Optional. Text for more than one comment. Default false.
 * @param string $deprecated Not used.
 */
function comments_number($zero = false, $one = false, $more = false, $deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '1.3');
    }
    $number = get_comments_number();
    if ($number > 1) {
        $output = str_replace('%', number_format_i18n($number), (false === $more) ? __('% Comments') : $more);
    } elseif ($number == 0) {
        $output = (false === $zero) ? __('No Comments') : $zero;
    } else {
        // must be one
        $output = (false === $one) ? __('1 Comment') : $one;
    }
    /**
     * Filter the comments count for display.
     *
     * @since 1.5.0
     *
     * @see _n()
     *
     * @param string $output A translatable string formatted based on whether the count
     *                       is equal to 0, 1, or 1+.
     * @param int    $number The number of post comments.
     */
    echo apply_filters('comments_number', $output, $number);
}

WordPress Version: 3.8

/**
 * Display the language string for the number of comments the current post has.
 *
 * @since 0.71
 *
 * @param string $zero       Optional. Text for no comments. Default false.
 * @param string $one        Optional. Text for one comment. Default false.
 * @param string $more       Optional. Text for more than one comment. Default false.
 * @param string $deprecated Not used.
 */
function comments_number($zero = false, $one = false, $more = false, $deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '1.3');
    }
    $number = get_comments_number();
    if ($number > 1) {
        $output = str_replace('%', number_format_i18n($number), (false === $more) ? __('% Comments') : $more);
    } elseif ($number == 0) {
        $output = (false === $zero) ? __('No Comments') : $zero;
    } else {
        // must be one
        $output = (false === $one) ? __('1 Comment') : $one;
    }
    /**
     * Filter the comments count for display.
     *
     * @since 1.5.0
     *
     * @param string $output A translatable string formatted based on whether the count is equal to 0, 1, or 1+. @see _n()
     * @param int    $number The number of post comments.
     */
    echo apply_filters('comments_number', $output, $number);
}

WordPress Version: 3.7

/**
 * Display the language string for the number of comments the current post has.
 *
 * @since 0.71
 *
 * @param string $zero       Optional. Text for no comments. Default false.
 * @param string $one        Optional. Text for one comment. Default false.
 * @param string $more       Optional. Text for more than one comment. Default false.
 * @param string $deprecated Not used.
 */
function comments_number($zero = false, $one = false, $more = false, $deprecated = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '1.3');
    }
    $number = get_comments_number();
    if ($number > 1) {
        $output = str_replace('%', number_format_i18n($number), (false === $more) ? __('% Comments') : $more);
    } elseif ($number == 0) {
        $output = (false === $zero) ? __('No Comments') : $zero;
    } else {
        // must be one
        $output = (false === $one) ? __('1 Comment') : $one;
    }
    /**
     * Filter the comments count for display.
     *
     * @since 1.5.2
     *
     * @param string $output A translatable string formatted based on whether the count is equal to 0, 1, or 1+. @see _n()
     * @param int    $number The number of post comments.
     */
    echo apply_filters('comments_number', $output, $number);
}