WordPress как на ладони

Как вывести комментарии под каждым постом на главной?

Ребята, помогите пожалуйста, почти неделю борюсь с этим вопросом.

Хочу сделать что бы на главной странице под каждым постом были видны комментарии к этому посту. Как это можно сделать?

0
Гость
7.7 лет назад
  • 0
    campusboy4750 www.youtube.com/c/wpplus

    Не надо с ним бороться, ведь есть супер приёмы! Это функция wp_list_comments (3 пример) или get_comments.

    Евген 7.7 лет назад

    Спасибо! Сегодня протестирую и дам знать помогли ли!
    Хорошего дня.

    Комментировать
  • 0

    Не получается.
    Вот пример.
    http://chromeblaze.com/wp/
    Я полтора часа потратил на копипаст в разные файлы, у меня всё равно не получается вывести комментарии под постами на главной странице, только форму отправки сообщения, которую я скопировал с comments.php и вставил в content.php

    Вот как выглядит content.php со вставленным кодом из comments.php
    Что я делаю не так в этом примере?

    <?php
    /**
     * @package Sydney
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    	<?php if ( has_post_thumbnail() && ( get_theme_mod( 'index_feat_image' ) != 1 ) ) : ?>
    		<div class="entry-thumb">
    			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('sydney-large-thumb'); ?></a>
    		</div>
    	<?php endif; ?>
    
    	<header class="entry-header">
    		<?php the_title( sprintf( '<h2 class="title-post"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
    
    		<?php if ( 'post' == get_post_type() && get_theme_mod('hide_meta_index') != 1 ) : ?>
    		<div class="meta-post">
    			<?php sydney_posted_on(); ?>
    		</div><!-- .entry-meta -->
    		<?php endif; ?>
    	</header><!-- .entry-header -->
    
    	<div class="entry-post">
    		<?php if ( (get_theme_mod('full_content_home') == 1 && is_home() ) || (get_theme_mod('full_content_archives') == 1 && is_archive() ) ) : ?>
    			<?php the_content(); ?>
    		<?php else : ?>
    			<?php the_content(); ?>
    		<?php endif; ?>
    
    			<?php comments_template(); ?>
    
    		<?php
    			wp_link_pages( array(
    				'before' => '<div class="page-links">' . __( 'Pages:', 'sydney' ),
    				'after'  => '</div>',
    			) );
    		?>
    	</div><!-- .entry-post -->
    
    	<footer class="entry-footer">
    		<?php sydney_entry_footer(); ?>
    	</footer><!-- .entry-footer -->
    </article><!-- #post-## -->
    
    <?php
    /**
     * The template for displaying comments.
     *
     * The area of the page that contains both current comments
     * and the comment form.
     *
     * @package Sydney
     */
    
    /*
     * If the current post is protected by a password and
     * the visitor has not yet entered the password we will
     * return early without loading the comments.
     */
    if ( post_password_required() ) {
    	return;
    }
    ?>
    
    <div id="comments" class="comments-area">
    
    	<?php // You can start editing here -- including this comment! ?>
    
    	<?php if ( have_comments() ) : ?>
    		<h4 class="comment-title">
    			<?php
    				printf( _nx( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'comments title', 'sydney' ),
    					number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
    			?>
    		</h4>
    
    		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
    		<nav id="comment-nav-above" class="comment-navigation" role="navigation">
    			<h1 class="screen-reader-text"><?php _e( 'Comment navigation', 'sydney' ); ?></h1>
    			<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'sydney' ) ); ?></div>
    			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'sydney' ) ); ?></div>
    		</nav><!-- #comment-nav-above -->
    		<?php endif; // check for comment navigation ?>
    
    		<ol class="comments-list">
    			<?php
    				wp_list_comments( array(
    					'style'      => 'ol',
    					'short_ping' => true,
    					'avatar_size'=> 60,
    				) );
    			?>
    		</ol><!-- .comment-list -->
    
    		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
    		<nav id="comment-nav-below" class="comment-navigation" role="navigation">
    			<h1 class="screen-reader-text"><?php _e( 'Comment navigation', 'sydney' ); ?></h1>
    			<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'sydney' ) ); ?></div>
    			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'sydney' ) ); ?></div>
    		</nav><!-- #comment-nav-below -->
    		<?php endif; // check for comment navigation ?>
    
    	<?php endif; // have_comments() ?>
    
    	<?php
    		// If comments are closed and there are comments, let's leave a little note, shall we?
    		if ( ! comments_open() && '0' != get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
    	?>
    		<p class="no-comments"><?php _e( 'Comments are closed.', 'sydney' ); ?></p>
    	<?php endif; ?>
    
    	<?php 
    		$args = array(
    			'comment_notes_after'  => '',
    		);
    		comment_form($args);
    	?>
    
    </div><!-- #comments -->
    
    Комментировать
На вопросы могут отвечать только зарегистрированные пользователи. Вход . Регистрация