如何让所有评论类型显示在 WordPress 中?

How do I get all comment types to display in WordPress?

我最近更改了博客的主题,它显然没有显示所有评论类型,所以我留下了很多帖子说他们有 X 条评论,但实际上有 none显示在页面上。

这是显示来自我的主题 comments.php 文件的评论的代码:

<?php wp_list_comments('callback=infinity_comments'); ?>

据我了解,我必须以某种方式包括以下内容:

( array( 'type' => 'all' ) )

问题是我真的不知道该怎么做。我不是开发人员,所以我的知识非常有限。

将不胜感激。

谢谢!

=====更新=====

@zipkundan 这似乎行得通,但好像评论没有任何 CSS 规则,而且它们都乱七八糟,所以现在就是这样。 (图片:https://i.imgur.com/u2ibqUA.png

这是 "infinity_comments" 函数:

if ( ! function_exists( 'infinity_comments' ) ) {

function infinity_comments ( $comment, $args, $depth ) {
$_GLOBAL['comment'] = $comment;

if(get_comment_type() == 'pingback' || get_comment_type() == 'trackback' ) : ?>

<li class="pingback" id="comment-<?php comment_ID(); ?>">
    <article <?php comment_class('entry-comments'); ?> >
        <div class="comment-content">
            <h3 class="comment-author">
                <?php esc_html_e( 'Pingback:', 'flexblog' ); ?>
            </h3>   
            <span class="comment-date" >
            <a href=" <?php echo esc_url( get_comment_link() ); ?> " class="comment-date" >
                <?php
                comment_date( get_option('date_format') );
                esc_html_e( '&nbsp;at&nbsp;', 'flexblog' );
                comment_time( get_option('time_format') );
                ?>
            </a>
            <?php
                echo edit_comment_link( esc_html__('&nbsp;[Edit]', 'flexblog' ) );
            ?>
            </span>
            <div class="clear"></div>
            <div class="comment-text">          
            <?php comment_author_link(); ?>
            </div>
        </div>
    </article>
</li>

<?php elseif (get_comment_type() == 'comment') : ?>

    <li id="comment-<?php comment_ID(); ?>">

        <article <?php comment_class('entry-comments'); ?> >                    
            <figure class="comment-avatar">
                <?php 
                    $avatar_size = 60;
                    if( $comment->comment_parent != 0 ) {
                        $avatar_size = 55;
                    }
                    echo get_avatar( $comment, $avatar_size );
                ?>
            </figure>
            <div class="comment-content">
            <h3 class="comment-author">
                <?php comment_author_link(); ?>
            </h3>
            <span class="comment-date" >
            <a href=" <?php echo esc_url( get_comment_link() ); ?> ">
                <?php
                comment_date( get_option('date_format') );
                esc_html_e( '&nbsp;at&nbsp;', 'flexblog' );
                comment_time( get_option('time_format') );
                ?>
            </a>
            <?php
                echo edit_comment_link( esc_html__('&nbsp;[Edit]', 'flexblog' ) );
            ?>
            </span>
            <div class="clear"></div>
            <div class="comment-text">
            <?php if($comment->comment_approved == '0') : ?>
            <p class="awaiting-moderation"><?php esc_html_e('Your comment is awaiting moderation.', 'flexblog'); ?></p>
            <?php endif; ?>
            <?php comment_text(); ?>
            </div>
            </div>
            <span class="reply">
                <?php comment_reply_link(array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth']) ) ); ?>
            </span> 
        </article>                          
<?php endif;
}
}

我尝试在 comments.php 中使用您的代码,并在 functions.php:

的这一行中将 "comment" 替换为 "all"
    <?php elseif (get_comment_type() == 'comment') : ?>

但没有任何改变。评论显示,但它们不遵循任何 CSS 规则。

知道如何解决这个问题吗?

谢谢!

=====更新二=====

在我上面提到的 functions.php 代码中,有这样的:

<?php elseif (get_comment_type() == 'comment') : ?>

如果我将 "comment" 替换为 "social-twitter" 或 "social-facebook"(目前没有出现的两种类型的评论,它有效,它们看起来很好。然而,这,使所有其他评论类型不出现。所以解决方案似乎很简单,我只需要在该行代码中提及 "comment"、"social-twitter" 和 "social-facebook",以便显示所有当前存在的评论类型. 我现在的问题是我应该如何格式化列表?我只是尝试写 'comment', 'social-facebook', 'social-twitter', 但那没有' 似乎工作。

正如您所提到的,您的 comments.php 文件中有以下行。

<?php wp_list_comments('callback=infinity_comments'); ?>

Update/change 跟进

<?php
     $arg = array(
         'callback'=>'infinity_comments',
         'type'=>'all'
     );
     wp_list_comments(); 
?>

如果这不能解决您的问题,那么问题出在您的新主题中的自定义函数 "infinity_comments" 中。在那找到你的新主题中的函数和 post 该函数的代码以供检查。

希望对您有所帮助。

有问题 "Update 2" 后更新。

在这种情况下,您可以尝试按如下方式更新 elseif。

<?php elseif (get_comment_type() == 'comment' || get_comment_type() == 'social-twitter' || get_comment_type() == 'social-facebook') : ?>

让我知道这是否有效。