前提・実現したいこと
ワードプレスでトップページの設定を固定ページでなく、最新の投稿を表示させています。
個別ページに出てくるコメント欄をトップ下にも表示させたいです。
すみませんが、よろしくお願いいたします。
テーマ:Twenty Seventeen2.0
発生している問題・エラーメッセージ
<?php comments_template(); ?> これをindex.phpに入力しても、コメント欄が表示されません。 呼び出し方法が間違っているのでしょうか。 逆に、comments.phpのコードをコピーして直に書き込んでみたところ、表示はされるのですが、 試しにコメントを入力してみましたが、入力したコメントが別のページに表示されてしまいトップページに溜まらない状態です。
該当のソースコード
<?php get_header(); ?> <div class="wrap"> <?php if ( is_home() && ! is_front_page() ) : ?> <header class="page-header"> <h1 class="page-title"><?php single_post_title(); ?></h1> </header> <?php else : ?> <header class="page-header"> <h2 class="page-title"><?php _e( 'Posts', 'twentyseventeen' ); ?></h2> </header> <?php endif; ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : /* Start the Loop */ while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'template-parts/post/content', get_post_format() ); endwhile; the_posts_pagination( array( 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>', 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>', ) ); else : get_template_part( 'template-parts/post/content', 'none' ); endif; ?> <?php comments_template(); ?><!-- ここに表示させたいです --> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> </div><!-- .wrap --> <?php get_footer(); ーーーーーーーーーー↓↓↓追記後↓↓↓ーーーーーーーーーー <?php get_header(); ?> <div class="wrap"> <?php if ( is_home() && ! is_front_page() ) : ?> <header class="page-header"> <h1 class="page-title"><?php single_post_title(); ?></h1> </header> <?php else : ?> <header class="page-header"> <h2 class="page-title"><?php _e( 'Posts', 'twentyseventeen' ); ?></h2> </header> <?php endif; ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : /* Start the Loop */ while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'template-parts/post/content', get_post_format() ); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; endwhile; the_posts_pagination( array( 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>', 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>', ) ); else : get_template_part( 'template-parts/post/content', 'none' ); endif; ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> </div><!-- .wrap --> <?php get_footer();
試したこと
・ワードプレス管理画面で、ディスカッション表示させ、全てのページでコメント許可にしています。
・一般>ディスカッション設定も許可状態になっています。
・管理画面>カスタマイズ>ホームページ設定>最新の投稿を選択しています。
・下から8行目にコメントのphpを入れてみたのですが表示されません。
補足情報(FW/ツールのバージョンなど)
ワードプレスver、4.9.9
テーマ:Twenty Seventeen2.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/04 07:13
2019/02/04 23:18
2019/02/11 07:27