下面告诉Wordpress使用类别博客显示所有帖子,
注释模板包含在底部,但在apge呈现时不显示。
有什么建议吗?
home.php:
<?php
/**
* Template Name: Blog
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<div id="main-content">
<?php query_posts('category_name=Blog&showposts=10'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_front_page() ) { ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php } else { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } ?>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php comments_template( '', true ); ?>
<?php endwhile; ?>
</div><!-- #main-content -->
<?php get_footer(); ?>发布于 2011-01-18 07:36:53
我认为问题在于,您试图以循环的方式使用comments_template(); --它只适用于单个帖子或页面模板。
参见:http://codex.wordpress.org/Function_Reference/comments_template引号:“描述--加载注释模板。用于单个post和页面显示。”
发布于 2012-08-24 15:28:09
如果有人想知道怎么做,就像这里所看到的,http://wordpress.org/support/topic/using-comments_template-outside-of-singlephp
<?php
$withcomments = 1;
comments_template(); ?>https://stackoverflow.com/questions/4720918
复制相似问题