1

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

谢谢您的帮助!马特

4

1 回答 1

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); ?>   
于 2013-06-07T11:54:35.727 回答