I have a really annoying problem.
If there are no comments, comments won’t show up.
If there are no pingbacks, won’t show up.
However, if there are pingbacks and I have a lot of comments, so there’s a page 2, page 3 etc. of comments, then the following happens:
The pingbacks show up properly on page 1.
If I go to page 2, I see the HTML markup for the Pingbacks, but no actual pingbacks.
I don’t understand why.
What I want is that either the same pingbacks as on page 1 show up or no HTML markup (and no pings) at all.
You can see the problem here.
On page one everything works fine, but on page 2 I only get the HTML markup for the pingbacks.
Here’s the code:
<?php if ( have_comments() ) : ?>
<?php if ( ! empty($comments_by_type['comment']) ) : ?>
<h2 class="h2comments"><img src="http://zoomingjapan.com/wp-content/themes/alltuts-child/images/comments_big.png" /><?php comments_number('No Comments', '1 Comment', '% Comments' );?> <a href="#respond" class="addComment"><img src="http://zoomingjapan.com/wp-content/themes/alltuts/images/add_your_coment_ver2.png" border="0"></a></h2>
<ul class="commentlist">
<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
<div class="navigation">
<?php paginate_comments_links(); ?>
</div>
</ul>
<?php endif; ?>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<h2 id="pings">Trackbacks/Pingbacks</h2>
<ul class="pinglist">
<?php wp_list_comments('type=pings&callback=list_pings'); ?>
</ul>
<?php endif; ?>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p class="nocomments">Comments are closed.</p>
<?php endif; ?>
<?php endif; ?>
What I already tried was to reposition or even remove the navigation. It didn’t change a thing.
Any other ideas?
EDIT: October 21st
If it doesn’t work to remove the HTML markup, then how about displaying a message within the HTML markup instead, something like “Sorry, but there are no pings yet.”
I tried this, but nothing is being displayed:
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<h2 id="pings">Trackbacks/Pingbacks</h2>
<ul class="pinglist">
<?php wp_list_comments('type=pings&callback=list_pings'); ?>
</ul>
<?php
else :
echo '<p class="no-pingbacks">sorry but there are no pingbacks yet</p>';
endif;
?>
I hope somebody can help.
Since you’re listing pings separately from comments, you probably need to filter
get_comments_number
to exclude pings. Here’s how I do it:I am fairly certain this will also impact the comments count with respect to comment pagination, as well. (Caveat: your pings list will output unpaginated.)
I was facing the same issue. Looks like I solved it. In case anyone else is facing this issue:
Replace this :
By this: