如果我使用
comments_template();
它根本不起作用。但如果我把它改成
global $withcomments;
$withcomments = 1;
comments_template( \'comments.php\', true );
它显示了评论模板,但我需要设置disqs插件,插件不工作。我不明白,出于某种原因,要显示评论是非常困难的。。
dev link
(试图截断不相关的代码以保持简短)index.php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( \'content\' );
}
} ?>
<小时>
content.php
<script>
jQuery(document).ready(function($) {
$( ".content" ).hide ();
$( ".entry-footer" ).hide ();
$( ".more" ).click ( function () {
$( this ).parent ().next ( \'.content\' ).show ( "blind", {direction : "vertical"}, 750 );
$( this ).next ( \'.entry-footer\' ).show ( "fast" );
$( this ).hide ();
} );
$( ".close" ).click ( function () {
$( this ).parent ( ".content" ).hide ( "blind", {direction : "vertical"}, 750 );
$( ".more" ).show ();
} );
} );
</script>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<?php get_template_part( \'content\', \'header\' ); ?>
<div class="entry-content">
<?php
$entrycontent = $lithograph_theme_options[\'excerpt_content\'];
if ( $entrycontent != \'\' ) {
switch ( $entrycontent ) {
case \'excerpt\':
if ( $lithograph_theme_options[\'slideout_content\'] == 0 ) the_excerpt();
else : ?>
<span class="excerpt" itemprop="text">
<?php
if(!empty($post->post_excerpt)) the_excerpt();
else : echo get_first_paragraph(); ?>
<span class="more">+ more</span>
</span>
<span class="content" itemprop="text">
<?php echo get_the_post(); ?>
<span class="close">- close</span>
<?php
get_template_part( \'content\', \'footer\' );
comments_template( \'comments.php\', true );
?>
</span>
<?php }
break;
case \'content\':
the_content();
global $withcomments;
$withcomments = 1;
comments_template( \'comments.php\', true );
break;
}
} ?>
</div>
</article>
(通用评论模板)
comments.php
<?php if($comments) { ?>
<ol>
<?php foreach($comments as $comment) { ?>
<li id="comment-<?php comment_ID(); ?>">
<?php if ($comment->comment_approved == \'0\') { ?>
<p>Your comment is awaiting approval</p>
<?php }
comment_text(); ?>
<cite><?php comment_type(); ?> by <?php comment_author_link(); ?> on <?php comment_date(); ?> at <?php comment_time(); ?></cite>
</li>
<?php } ?>
</ol>
<?php } else { ?>
<p>No comments yet</p>
<?php } ?>