have_comments

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

WordPress Version: 6.1

/*
 * Comments loop.
 */
/**
 * Determines whether current WordPress query has comments to loop over.
 *
 * @since 2.2.0
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @return bool True if comments are available, false if no more comments.
 */
function have_comments()
{
    global $wp_query;
    if (!isset($wp_query)) {
        return false;
    }
    return $wp_query->have_comments();
}

WordPress Version: 5.5

/*
 * Comments loop.
 */
/**
 * Determines whether current WordPress query has comments to loop over.
 *
 * @since 2.2.0
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @return bool True if comments are available, false if no more comments.
 */
function have_comments()
{
    global $wp_query;
    return $wp_query->have_comments();
}

WordPress Version: 5.3

/*
 * Comments loop.
 */
/**
 * Whether there are comments to loop over.
 *
 * @since 2.2.0
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @return bool
 */
function have_comments()
{
    global $wp_query;
    return $wp_query->have_comments();
}

WordPress Version: 4.4

/*
 * Comments loop.
 */
/**
 * Whether there are comments to loop over.
 *
 * @since 2.2.0
 *
 * @global WP_Query $wp_query Global WP_Query instance.
 *
 * @return bool
 */
function have_comments()
{
    global $wp_query;
    return $wp_query->have_comments();
}

WordPress Version: 4.3

/*
 * Comments loop.
 */
/**
 * Whether there are comments to loop over.
 *
 * @since 2.2.0
 *
 * @global WP_Query $wp_query
 *
 * @return bool
 */
function have_comments()
{
    global $wp_query;
    return $wp_query->have_comments();
}

WordPress Version: 3.7

/*
 * Comments loop.
 */
/**
 * Whether there are comments to loop over.
 *
 * @see WP_Query::have_comments()
 * @since 2.2.0
 * @uses $wp_query
 *
 * @return bool
 */
function have_comments()
{
    global $wp_query;
    return $wp_query->have_comments();
}