如何让 Wordpress 在首页上只显示一篇带有评论和评论表格的帖子? [英] How to make Wordpress show only one post on the front page with comments, and comment form?
本文介绍了如何让 Wordpress 在首页上只显示一篇带有评论和评论表格的帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我执行以下操作以在我的主页中显示单个帖子:
home.php:
<div id="内容"><?php/* 运行循环以输出帖子.* 如果您想在子主题中重载它,请包含一个文件* 调用 loop-index.php 并将使用它.*/get_template_part('循环','索引');?>
<div id="侧边栏"><?php get_sidebar();?>
<div id="页脚"><?php get_footer();?>
但我仍然需要点击Comments
才能看到评论和留下评论的表格.如何立即自动显示?
解决方案
使用 <?php comments_template(); 加载评论模板?>
- 将显示当前帖子的所有评论.
I did the following to display a single post in my home page:
home.php:
<?php
get_header();
query_posts('posts_per_page=1'); //returns only the front page
?>
<div id="content">
<?php
/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-index.php and that will be used instead.
*/
get_template_part( 'loop', 'index' );
?>
</div>
<div id="sidebar">
<?php get_sidebar(); ?>
</div>
<div id="footer">
<?php get_footer(); ?>
But I still ahave to click Comments
in order to see the comments and the form to leave a comment. How can I automatically show immediately?
解决方案
Load the comments template using <?php comments_template(); ?>
- that'll display all comments for the current post.
这篇关于如何让 Wordpress 在首页上只显示一篇带有评论和评论表格的帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文