【问题标题】:Issue pulling wordpress comments拉动wordpress评论的问题
【发布时间】:2013-05-28 03:34:58
【问题描述】:

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

感谢您的帮助! 马特

【问题讨论】:

  • "关于“测试#1”的 4 条想法" -> 批准一个并检查它们是否显示在评论线程下..让我知道情况(查看您的 cmets 设置)..还要检查您是否有评论模板,例如 在你的 single.php 文件中
  • 看到您发表了评论。我的 cmets 的设置方式不需要我批准它们。在single.php 中,我使用<?php comments_template(); ?>。 cmets 不会显示在帖子下方,但会显示在我的仪表板下的 cmets 选项卡上。

标签: wordpress wordpress-theming


【解决方案1】:

尝试使用它。这就是我所说的 cmets。

在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); ?>   

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-26
    • 2011-01-16
    • 2012-09-06
    • 1970-01-01
    相关资源
    最近更新 更多