我使用
设计我自己的评论<?php
if (post_password_required())
return;
?>
<div class="left">
<?php
global $post;
$number_of_comments = wp_count_comments($post->ID);
comments_number('0 Replies', 'One Reply', "$number_of_comments->approved Replies");
?>
</div>
<?php
$sfp_reply = get_comments("post_id=$post->ID");
if ($sfp_reply) :
?>
<?php
foreach ($sfp_reply as $comment)
{
$comment_user = get_userdata($comment->user_id);
?>
<section class='post-thread' id="comment-<?php comment_ID(); ?>">
<div class="thread-post-detail">
<div class="thread-user-pic">
<?php
echo "<img class='img-responsive' src='" . get_picture($comment->comment_author, 75) . "' />"
?>
</div>
<div class="thread-user-info">
<a href="<?php echo site_url() . "/author/" . $comment_user->user_login ?>">
<div class='thread_user_name'><strong><?php echo ucfirst($comment_user->first_name); ?></strong></div>
<div class='thread_user_name'><strong><?php echo ucfirst($comment_user->last_name); ?></strong></div>
</a>
<div class="user-join-date">Joined <?php
$join_date_time = $comment_user->user_registered;
$join_date = new DateTime($join_date_time);
echo $join_date = $join_date->format('m.d.y');
?>
</div>
<div class="sfpuserreply">
<div class="sfpicon-text left fblikelogo">Likes</div>
<div class="user-social-count left "><?php
if ($userlikes = get_user_meta($comment_user->ID, 'sfp_user_like_count'))
echo $userlikes[0];
else
echo 0;
?>
</div>
</div>
<div class="sfpuserreply">
<div class="sfpicon-text left fbsharelogo">Share</div>
<div class="user-social-count left">
<?php
if ($usershare = get_user_meta($comment_user->ID, 'sfp_user_fb_share'))
echo $usershare[0];
else
echo 0;
?>
</div>
</div>
<div class="sfpuserreply">
<div class="sfpicon-text left">Replies</div>
<div class="user-social-count left"><?php $comments = get_comments('user_id=' . $comment_user->ID);
echo count($comments); ?></div>
</div>
</div>
</div>
<div class="thread-post-content">
<div class="thread-posted">Posted
<?php
$post_time_date = $comment->comment_date;
$post_time_date = new DateTime($post_time_date);
echo $post_time_date->format('d.m.Y') . " @ " . $post_time_date->format('H:i A');
?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<p>Your comment is awaiting approval</p>
<?php endif; ?>
<div class="thread_single_content"><?php echo nl2br($comment->comment_content); ?></div>
</div>
<div class="comment-reply-data">
<?php
// var_dump($comment);
var_dump(comment_reply_link('', $comment->comment_ID, $post->ID)); ?>
</div>
</section>
<?php }
endif;
?>
<?php
if (is_user_logged_in())
{
echo "<div class='left comment-box'>";
?>
<?php if (comments_open()) : ?>
<form action="<?php echo get_option('siteurl'); ?>/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>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out »</a></p>
<input name="submit" type="submit" id="submit" tabindex="5" value="Reply" class="comment-reply"/>
<?php endif; ?>
<?php wp_editor('', 'comment', $settings = array('media_buttons' => true, 'textarea_rows' => 10)); ?>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php else : ?>
<p>The comments are closed.</p>
<?php endif; ?>
<?php
echo "</div>";
}else
{
?>
<div class="post-thread">
<center>
<div class="sfbutton">
<a href="#" onclick=' fb_login("<?php echo get_permalink($post->ID) ?>");'> </a>
</div>
</center>
</div>
<?php
}?>
你可以看到
var_dump(comment_reply_link('', $comment->comment_ID, $post->ID));)
每当我得到null
时,我也会启用5级的嵌套回复,但仍然从该函数获取null
答案 0 :(得分:0)
包括评论回复脚本......
<?php
add_action('wp_enqueue_scripts', 'theme_print_scripts');
function theme_print_scripts(){
if( is_singular() ) wp_enqueue_script('comment-reply');
}
?>
享受吧。 ;)