1.wordpress怎样显示文章评论
1、在wordpress模板的index.php文件中的文章调用循环内,while (have_posts()) : the_post();和endwhile;之间适当位置,添加以下代码: 2、示例: 3、原理:使用全局变量$withcomments,并将其值改成true(改成这样也是可以的$withcomments = 1;)。
接着包含用于在首页显示评论的模板opinion.php,如想使用默认评论模板comments.php,改成comments_template();该方法可用于分类页、标签页、日期归档页等。
2.wordpress评论代码求助
<?php
if ( post_password_required() ) { ?>
<p>This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
if( have_comments() ) : ?>
<h5 class="cufon"><?php comments_number('No comment', 'Comment', '% Comments'); ?> for <?php the_title(); ?></h5><br/>
<?php wp_list_comments( array('callback' => 'pp_comment', 'avatar_size' => '40') ); ?>
<!-- End of thread -->
<br class="clear"/><br/>
<?php endif; ?>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
<div class="pagination"><p><?php previous_comments_link(); ?> <?php next_comments_link(); ?></p></div><br class="clear"/><div class="line"></div><br/><br/>
<?php endif; // check for comment navigation ?>
<?php if ('open' == $post->comment_status) : ?>
<div id="respond">
<?php include(TEMPLATEPATH . '/templates/comments-form.php'); ?>
</div>
<?php endif; ?>
3.如何实现wordpress评论回复邮件通知功能
/* comment_mail_notify v1.0 by willin kan. (所有回复都发邮件) */function comment_mail_notify($comment_id) { $comment = get_comment($comment_id); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; $spam_confirmed = $comment->comment_approved; if (($parent_id != '') && ($spam_confirmed != 'spam')) { $wp_email = 'no-reply@' . preg_replace('#^ment($parent_id)->comment_author_email); $subject = '您在 [' . get_option("blogname") . '] 的留言有了回复'; $message = ' ' . trim(get_comment($parent_id)->comment_author) . ', 您好! 您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:' . trim(get_comment($parent_id)->comment_content) . ' ' . trim($comment->comment_author) . ' 给您的回复:' . trim($comment->comment_content) . ' 您可以点击 查看回复完整内容 欢迎再度光临 ' . get_option('blogname') . ' (此邮件由系统自动发送,请勿回复.) '; $from = "From: \"" . get_option('blogname') . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; wp_mail( $to, $subject, $message, $headers ); }}add_action('comment_post', 'comment_mail_notify');// -- END ----------------------------------------。
4.wordpress评论代码求助
<?phpif (="" post_password_required()="" )="" {="">?phpif>This post is password protected. Enter the password to view comments.<?phpreturn;}if( have_comments() ) : ?>
<?php comments_number('No comment', 'Comment', '% Comments'); ?> for <?php the_title(); ?>
<?php wp_list_comments( array('callback' => 'pp_comment', 'avatar_size' => '40') ); ?> <?php endif; ?> <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?><?php previous_comments_link(); ?> <?php next_comments_link(); ?><?php endif; // check for comment navigation ?><?php if ('open' == $post->comment_status) : ?> <?php include(TEMPLATEPATH . '/templates/comments-form.php'); ?><?php endif; ?>。转载请注明出处51数据库 » wordpresscomments_p
$wp_email>
只怪缘浅