首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拉取wordpress评论时出现问题

拉取wordpress评论时出现问题
EN

Stack Overflow用户
提问于 2013-05-28 11:34:58
回答 1查看 102关注 0票数 1

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

谢谢你的帮助!哑光

EN

回答 1

Stack Overflow用户

发布于 2013-06-07 19:54:36

试着用这个。这就是我用来调用评论的东西。

在functions.php中:

代码语言:javascript
复制
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

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

代码语言:javascript
复制
<?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); ?>   
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16783497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档