Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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:

<?php
function oenology_comment_count( $count ) {  
// Only filter the comments number
// in the front-end display
if ( 
// WordPress conditional that returns true if
// the current page is in the WP-Admin back-end
! is_admin() 
) {
    global $id;
    $comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
    return count( $comments_by_type['comment'] );
} 
// Otherwise, when in the WP-Admin
// back end, don't filter comments
// number
else {
    return $count;
}
}
// Hook custom comment number into 'get_comments_number'
add_filter('get_comments_number', 'oenology_comment_count', 0);
?>

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.)

share|improve this answer
    
Thank you for your answer. So I've put the code into my function.php. Where in my code above should I call the function in order to make it work properly? –  japanworm Oct 18 '11 at 13:41
    
This is a filter; you don't need to add any code to your template files. –  Chip Bennett Oct 18 '11 at 13:44
    
Oh, I'm asking because after I've added the code, I still have the exact same problem as before, so it didn't work, I'm afraid. –  japanworm Oct 18 '11 at 13:56
    
Hello again :) As this didn't work out, do you have any other ideas how to solve this? Thanks a lot! –  japanworm Oct 20 '11 at 14:23
    
Please see my updated question :) –  japanworm Oct 21 '11 at 8:43

I was facing the same issue. Looks like I solved it. In case anyone else is facing this issue:

Replace this :

wp_list_comments('type=pings&callback=list_pings');

By this:

wp_list_comments('type=pings&callback=list_pings&page=1&per_page=1000');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.