WordPress is not showing number of comments per post
-
so im trying to make wordpress loop with nubmer of comments show per post. I just want posts from one category. Loop is working, but number of comments are not correct. On every single post it just say that there is no comments (even when i have 10 or more commentes there)
<?php $query = new WP_Query('category_name=blog&post_type=post'); if ($query->have_posts()) : ?> <?php // Start the loop. while ($query->have_posts()) : $query->the_post(); ?> <div class="col-12 col-md-6 blog_single_homepage"> <div class="col-12"> <div class="row align-items-end"> <div class="col-5 col-md-3 autor_section"> <?php echo get_avatar( get_the_author_meta('user_email'), '150', $default, $alt, array( 'class' => array( 'rounded-circle' ) ) ); ?> </div> <div class="col-7 col-md-9 autor_info"> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>" class="autor_name"><?php the_author(); ?></a> <span class="align-middle"><?php the_time('d/m/Y'); ?></span> <div class="cat"> <p><?php the_category(', '); ?></p> </div> <hr> </div> </div> </div> <div class="col-12 blog_content_short"> <a href="<?php the_permalink(); ?>"> <h3><?php the_title() ?></h3> <p><?php echo wp_trim_words(get_the_content(), 50); ?></p> <div class="read_more_over"> <div class="title_inner"> <?php the_title() ?> </div> <div class="inner_show"> Read more </div> </div> </a> <div class="comments"> <?php printf( _nx( 'One Comment', '%1$s Comments', get_comments_number(), 'comments title', 'textdomain' ), number_format_i18n( get_comments_number() ) ); ?> </div> </div> </div> <?php // End the loop. endwhile; else : echo 'No blog posts...'; endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘WordPress is not showing number of comments per post’ is closed to new replies.