问题拉wordpress评论

时间:2013-05-28 03:34:58

标签: wordpress wordpress-theming

我正在使用Twitter的Bootstrap创建一个简单的主题。我只使用wordpress作为我网站的博客部分(http://www.mattaltepeter.com/n3)。在我的single.php文件中,我用来引入评论模板。最后我想使用Jetpack注释,但只是尝试使用当前的默认wordpress。我创建了一个测试帖并添加了几条评论,但评论没有显示在帖子上。我把我的主题改为二十一,他们做了,所以它必须是我的主题。我认为问题出在我的comments.php上。我不完全确定要放在那里使它工作。我刚开始研究这个问题,不记得我在哪里获得了目前驻留在comments.php中的代码。我试图复制并粘贴二十一个comments.php中的代码,但这也没有用。我是否需要为此创建自定义代码或什么?

感谢您的帮助! 马特

1 个答案:

答案 0 :(得分:0)

尝试使用此功能。这就是我用来调用评论的内容。

在functions.php中:

function custom_comments($comment, $args, $depth) {
  $GLOBALS['comment'] = $comment;
    $GLOBALS['comment_depth'] = $depth;
      ?>
        <li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
            <div class="comment-author vcard"><?php commenter_link() ?></div>
            <div class="comment-meta"><?php printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> <a href="%3$s" title="Permalink to this comment">Permalink</a>', 'your-theme'),
                        get_comment_date(),
                        get_comment_time(),
                        '#comment-' . get_comment_ID() );
                        edit_comment_link(__('Edit', 'your-theme'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
      <?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'your-theme') ?>
              <div class="comment-content">
                <?php comment_text() ?>
            </div>
            <?php // echo the comment reply link
                if($args['type'] == 'all' || get_comment_type() == 'comment') :
                    comment_reply_link(array_merge($args, array(
                        'reply_text' => __('Reply','your-theme'), 
                        'login_text' => __('Log in to reply.','your-theme'),
                        'depth' => $depth,
                        'before' => '<div class="comment-reply-link">', 
                        'after' => '</div>'
                    )));
                endif;
            ?>
    <?php } // end custom_comments

在你的帖子中,在循环中:

<?php if ( ('open' == $post->comment_status) && ('open' == $post->ping_status) ) : // Comments and trackbacks open ?>
                        <?php printf( __( '<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'your-theme' ), get_trackback_url() ) ?>
<?php elseif ( !('open' == $post->comment_status) && ('open' == $post->ping_status) ) : // Only trackbacks open ?>
                        <?php printf( __( 'Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'your-theme' ), get_trackback_url() ) ?>
<?php elseif ( ('open' == $post->comment_status) && !('open' == $post->ping_status) ) : // Only comments open ?>
                        <?php _e( 'Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'your-theme' ) ?>
<?php elseif ( !('open' == $post->comment_status) && !('open' == $post->ping_status) ) : // Comments and trackbacks closed ?>
                        <?php _e( 'Both comments and trackbacks are currently closed.', 'your-theme' ) ?>

<?php comments_template('', true); ?>