我使用的是wordpress的3.3.1版,但我遵循的是使用2.7版的教程。更改标题后。php和注释。php代码,当我查看带有注释的单个帖子页面时,我得到了一个无限循环。
这是我在<head>
标题中的标记。php:
<?php if(is_singular()){ wp_enqueue_script(\'comment-reply\');} ?>
<?php wp_head(); ?>
以下是完整的评论。php代码:
<?php
if(!empty($_SERVER[\'SCRIPT_FILENAME\']) && \'comments.php\' == basename($_SERVER[\'SCRIPT_FILENAME\'])){
die(\'Please do not load this page directly!\');
}
if(post_password_required()){
?>
<p>This post is password protected.</p>
<?php
return;
} ?>
<?php
//Display the comment loop
if(have_posts()) {
?>
<h2><?php comments_number(\'Be the first to comment!\', \'One Comment\', \'% Comments\'); ?></h2>
<ol id=\'comments_section\'>
<?php wp_list_comments(array(\'avatar_size\'=>80, \'reply_text\'=>\'Reply to this comment.\')); ?>
</ol>
<div><?php paginate_comments_links(); ?></div>
<?php
}else {
//If no comments so far
if(\'open\' == $post->comment_status) {
?>
<p>Have your say!</p>
<?php
} else {
?>
<p>Comments currently closed!</p>
<?php
}
}
if(\'open\' == $post->comment_status) {
?>
<div id=\'respond\'>
<h2><?php comment_form_title(); ?></h2>
<div id=\'cancel-comment-reply\'>
<small><?php cancel_comment_reply_link(); ?></small>
</div>
<?php
if(get_option(\'comment_registration\') && !$user_ID){
?>
<p>You must be logged in to comment</p>
<?php
} else {
?>
<form action="<?php echo get_option(\'site_url\'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php
if($user_ID) {
?>
<p>Logged in as <a href="<?php echo get_option(\'siteurl\'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a></p>
<?php
} else {
?>
<p>
<input type=\'text\' name=\'author\' id=\'author\' value="<?php echo $comment_author;?>" />
<label for=\'author\'>Name</label>
</p>
<p>
<input type=\'text\' name=\'email\' id=\'email\' value="<?php echo $comment_author_email;?>" />
<label for=\'email\'>Mail <?php if($req) echo \'(Required field)\';?></label>
</p>
<p>
<input type=\'text\' name=\'url\' id=\'url\' value="<?php echo $comment_author_url; ?>" />
<label for=\'url\'>Website</label>
</p>
<?php
}
?>
<div>
<?php comment_id_fields(); ?>
<input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER[\'REQUEST_URI\'])?>" />
</div>
<p><textarea id=\'comment\' name=\'comment\' cols=\'50\' rows=\'10\'></textarea></p>
<?php
if(get_option(\'comment_moderation\') == \'1\'){
?>
<p>Comment moderation is enabled, no need to resubmit any comments posted.</p>
<?php
}
?>
<p><input type=\'text\' name=\'submit\' id=\'submit\' value=\'Submit\' /></p>
<?php do_action(\'comment_form\', $post->ID); ?>
</form>
<?php
}
?>
</div>
<?php
}
如果仅删除标题,则循环将持续。php代码。不更改注释。php,看起来标签之间的单个帖子和注释表单代码都是无限循环的。如果我删除标签之间的注释表单代码,那么单个帖子仍然是无限循环的。我观看的教程视频没有显示这个无限循环问题,但我使用的是确切的代码作为教程。
更新时间:
我遵循的教程是this one
single.php
pastebin