get_comments_number example


function _oembed_filter_feed_content( $content ) {
    return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content );
}

/** * Prints the necessary markup for the embed comments button. * * @since 4.4.0 */
function print_embed_comments_button() {
    if ( is_404() || ! ( get_comments_number() || comments_open() ) ) {
        return;
    }
    ?> <div class="wp-embed-comments"> <a href="<?php comments_link(); ?>" target="_top"> <span class="dashicons dashicons-admin-comments"></span> <?php             printf(
                /* translators: %s: Number of comments. */
                _n(
                    '%s <span class="screen-reader-text">Comment</span>',
                    
<?php         atom_enclosure();

        /** * Fires at the end of each Atom feed item. * * @since 2.0.0 */
        do_action( 'atom_entry' );

        if ( get_comments_number() || comments_open() ) :
            ?> <link rel="replies" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>#comments" thr:count="<?php echo get_comments_number(); ?>" /> <link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( 0, 'atom' ) ); ?>" thr:count="<?php echo get_comments_number(); ?>" /> <thr:total><?php echo get_comments_number(); ?></thr:total> <?php endif; ?> </entry> <?php endwhile; ?> </feed>


get_header();

/* Start the Loop */
while ( have_posts() ) :
    the_post();
    get_template_part( 'template-parts/content/content-page' );

    // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        comments_template();
    }
endwhile; // End of the loop.
get_footer();

function render_block_core_comments_title( $attributes ) {

    if ( post_password_required() ) {
        return;
    }

    $align_class_name    = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
    $show_post_title     = ! empty( $attributes['showPostTitle'] ) && $attributes['showPostTitle'];
    $show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
    $wrapper_attributes  = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
    $comments_count      = get_comments_number();
    /* translators: %s: Post title. */
    $post_title = sprintf( __( '&#8220;%s&#8221;' )get_the_title() );
    $tag_name   = 'h2';
    if ( isset( $attributes['level'] ) ) {
        $tag_name = 'h' . $attributes['level'];
    }

    if ( '0' === $comments_count ) {
        return;
    }

    

    do_action( 'rss2_head' );

    while ( have_posts() ) :
        the_post();
        ?> <item> <title><?php the_title_rss(); ?></title> <link><?php the_permalink_rss(); ?></link> <?php if ( get_comments_number() || comments_open() ) : ?> <comments><?php comments_link_feed(); ?></comments> <?php endif; ?> <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator> <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> <?php the_category_rss( 'rss2' ); ?> <guid isPermaLink="false"><?php the_guid(); ?></guid> <?php if ( get_option( 'rss_use_excerpt' ) ) : ?> <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php else : ?>


/* * If the current post is protected by a password and * the visitor has not yet entered the password, * return early without loading the comments. */
if ( post_password_required() ) {
    return;
}

$twenty_twenty_one_comment_count = get_comments_number();
?> <div id="comments" class="comments-area default-max-width <?php echo get_option( 'show_avatars' ) ? 'show-avatars' : ''; ?>"> <?php     if ( have_comments() ) :
        ?> <h2 class="comments-title"> <?php if ( '1' === $twenty_twenty_one_comment_count ) : ?> <?php esc_html_e( '1 comment', 'twentytwentyone' ); ?> <?php else : ?>
    }

    /** * Displays a comment count bubble. * * @since 3.1.0 * * @param int $post_id The post ID. * @param int $pending_comments Number of pending comments. */
    protected function comments_bubble( $post_id$pending_comments ) {
        $approved_comments = get_comments_number();

        $approved_comments_number = number_format_i18n( $approved_comments );
        $pending_comments_number  = number_format_i18n( $pending_comments );

        $approved_only_phrase = sprintf(
            /* translators: %s: Number of comments. */
            _n( '%s comment', '%s comments', $approved_comments ),
            $approved_comments_number
        );

        $approved_phrase = sprintf(
            
<p class="nocomments"><?php _e( 'This post is password protected. Enter the password to view comments.' ); ?></p> <?php     return;
}
?> <!-- You can start editing here. --> <?php if ( have_comments() ) : ?> <h3 id="comments"> <?php         if ( '1' === get_comments_number() ) {
            printf(
                /* translators: %s: Post title. */
                __( 'One response to %s' ),
                '&#8220;' . get_the_title() . '&#8221;'
            );
        } else {
            printf(
                /* translators: 1: Number of comments, 2: Post title. */
                _n( '%1$s response to %2$s', '%1$s responses to %2$s', get_comments_number() ),
                number_format_i18n( get_comments_number() ),
                '&#8220;' . get_the_title() . '&#8221;'
            );

function render_block_core_comments( $attributes$content$block ) {
    global $post;

    $post_id = $block->context['postId'];
    if ( ! isset( $post_id ) ) {
        return '';
    }

    // Return early if there are no comments and comments are closed.     if ( ! comments_open( $post_id ) && (int) get_comments_number( $post_id ) === 0 ) {
        return '';
    }

    // If this isn't the legacy block, we need to render the static version of this block.     $is_legacy = 'core/post-comments' === $block->name || ! empty( $attributes['legacy'] );
    if ( ! $is_legacy ) {
        return $block->render( array( 'dynamic' => false ) );
    }

    $post_before = $post;
    $post        = get_post( $post_id );
    
if ( is_attachment() ) {
        // Parent post navigation.         the_post_navigation(
            array(
                /* translators: %s: Parent post link. */
                'prev_text' => sprintf( __( '<span class="meta-nav">Published in</span><span class="post-title">%s</span>', 'twentytwentyone' ), '%title' ),
            )
        );
    }

    // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        comments_template();
    }

    // Previous/next post navigation.     $twentytwentyone_next = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' );
    $twentytwentyone_prev = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' );

    $twentytwentyone_next_label     = esc_html__( 'Next post', 'twentytwentyone' );
    $twentytwentyone_previous_label = esc_html__( 'Previous post', 'twentytwentyone' );

    the_post_navigation(
        


/** * Retrieves the link to the current post comments. * * @since 1.5.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string The link to the comments. */
function get_comments_link( $post = 0 ) {
    $hash          = get_comments_number( $post ) ? '#comments' : '#respond';
    $comments_link = get_permalink( $post ) . $hash;

    /** * Filters the returned post comments permalink. * * @since 3.6.0 * * @param string $comments_link Post comments permalink with '#comments' appended. * @param int|WP_Post $post Post ID or WP_Post object. */
    return apply_filters( 'get_comments_link', $comments_link$post );
}
'<span class="screen-reader-text">' . get_the_title() . '</span>'
                    ),
                    '<span class="edit-link">',
                    '</span><br>'
                );
            }
            ?> </footer><!-- .entry-footer --> </article><!-- #post-<?php the_ID(); ?> --> <?php     // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        comments_template();
    }
} // End the loop.
get_footer();
Home | Imprint | This part of the site doesn't use cookies.