I've recently changed my blog's theme and it apparently doesn't display all comment types, so I'm left with a lot of posts that say they have X comments, but none of them actually show up on the page.
This is the code for displaying comments from my theme's comments.php file:
<?php wp_list_comments('callback=infinity_comments'); ?>
From what I understand, I have to somehow include this:
( array( 'type' => 'all' ) )
Problem is I can't really figure out how to do it. I'm not a developer so my knowledge is pretty limited.
Help would be greatly appreciated.
Thank you!
===== Update =====
@zipkundan That seems to work, but it's like the comments don't have any CSS rules and they're all messed up, so now there's that. (pic: https://i.imgur.com/u2ibqUA.png)
Here's the "infinity_comments" function:
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( ' at ', 'flexblog' );
comment_time( get_option('time_format') );
?>
</a>
<?php
echo edit_comment_link( esc_html__(' [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( ' at ', 'flexblog' );
comment_time( get_option('time_format') );
?>
</a>
<?php
echo edit_comment_link( esc_html__(' [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;
}
}
I tried using your code in comments.php and replacing "comment" with "all" in this line in functions.php:
<?php elseif (get_comment_type() == 'comment') : ?>
but nothing changed. The comments display, but they're not following any CSS rules.
Any idea how to fix that?
Thank you!
===== Update 2 =====
In the functions.php code I mentioned above, there's this:
<?php elseif (get_comment_type() == 'comment') : ?>
If I replace "comment" with "social-twitter" or "social-facebook" (the two types of comments that currently don't appear, it works, they appear just fine. This, however, makes all other comment types not appear. So the solution seems pretty simple, I just need to mention "comment", "social-twitter", and "social-facebook" in that line of code so all currently existing comment types appear. The question I have now is how exactly should I format the list? I just tried writing 'comment', 'social-facebook', 'social-twitter', but that doesn't seem to work.
As you have mentioned you have following line in your comments.php file.
<?php wp_list_comments('callback=infinity_comments'); ?>
Update/change it to following.
<?php
$arg = array(
'callback'=>'infinity_comments',
'type'=>'all'
);
wp_list_comments();
?>
If this does not solve your problem, then the problem lies within the custom function "infinity_comments" in your new theme. In that find that function in you new theme and post that function's code for examination.
Hope this helps.
Update after "Update 2" in question.
In that case you can try and update the elseif as follows.
<?php elseif (get_comment_type() == 'comment' || get_comment_type() == 'social-twitter' || get_comment_type() == 'social-facebook') : ?>
Let me know if this works.