WordPress主题开发之评论模块

WordPress主题开发之评论模块,新建comments.php,使用<?php comments_template(); ?>。

<?php

if ( !comments_open() ) :

// If registration required and not logged in.

elseif ( get_option(‘comment_registration’) && !is_user_logged_in() ) :

?>

<p>你必须 <a href=”<?php echo wp_login_url( get_permalink() ); ?>”>登录</a> 才能发表评论.</p>

<?php else : ?>

<!– Comment Form –>

<form id=”commentform” name=”commentform” action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post”>

<h3>发表评论</h3>

<div class=”hr dotted clearfix”> </div>

<ul>

<?php if ( !is_user_logged_in() ) : ?>

<li class=”clearfix”>

<label for=”name”>昵称</label>

<input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”23″ tabindex=”1″ />

</li>

<li class=”clearfix”>

<label for=”email”>电子邮件</label>

<input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”23″ tabindex=”2″ />

</li>

<li class=”clearfix”>

<label for=”email”>网址(选填)</label>

<input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”23″ tabindex=”3″ />

</li>

<?php else : ?>

<li class=”clearfix”>您已登录:<a href=”<?php echo get_option(‘siteurl’); ?>/wp-admin/profile.php”><?php echo $user_identity; ?></a>. <a href=”<?php echo wp_logout_url(get_permalink()); ?>” title=”退出登录”>退出 »</a></li>

<?php endif; ?>

<li class=”clearfix”>

<label for=”message”>评论内容</label>

<textarea id=”message comment” name=”comment” tabindex=”4″ rows=”3″ cols=”40″></textarea>

</li>

<li class=”clearfix”>

<!– Add Comment Button –>

<a href=”javascript:void(0);” onClick=”Javascript:document.forms[‘commentform’].submit()” class=”button medium black right”>发表评论</a> </li>

</ul>

<?php comment_id_fields(); ?>

<?php do_action(‘comment_form’, $post->ID); ?>

</form>

<?php endif; ?>

function aurelius_comment($comment, $args, $depth)

{

$GLOBALS[‘comment’] = $comment; ?>

<li class=”comment” id=”li-comment-<?php comment_ID(); ?>”>

<div class=”gravatar”> <?php if (function_exists(‘get_avatar’) && get_option(‘show_avatars’)) { echo get_avatar($comment, 48); } ?>

<?php comment_reply_link(array_merge( $args, array(‘reply_text’ => ‘回复’,’depth’ => $depth, ‘max_depth’ => $args[‘max_depth’]))) ?> </div>

<div class=”comment_content” id=”comment-<?php comment_ID(); ?>”>

<div class=”clearfix”>

<?php printf(__(‘<cite class=”author_name”>%s</cite>’), get_comment_author_link()); ?>

<div class=”comment-meta commentmetadata”>发表于:<?php echo get_comment_time(‘Y-m-d H:i’); ?></div>

<?php edit_comment_link(‘修改’); ?>

</div>

<div class=”comment_text”>

<?php if ($comment->comment_approved == ‘0’) : ?>

<em>你的评论正在审核,稍后会显示出来!</em><br />

<?php endif; ?>

<?php comment_text(); ?>

</div>

</div>

<?php } ?>

WordPress主题开发之评论模块 (https://www.wp-admin.cn/) WordPress开发教程 第1张

相关推荐

发表回复

房先生
我们将24小时内回复。
2024-07-16 16:48:12
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[QQ客服]
2781198
加我微信
[电话联系]
13585372227
[电子邮件]
chaoneo@163.com
取消

选择聊天工具: