Archived topic
separate pingbacks from comments
9 replies · Started by Anonymous on June 16, 2015
Hi Tom,
I'd like to separate pingbacks from comments on post pages. Right now pingbacks are listed at the bottom of comment list. I'd like to have the headline „PINGBACKS“ just before pingbacks will be listed.
The order should be like this
headline „COMMENTS“
comment-list
headline „PINGBACKS“
pingpack-list
Any help is welcome
Best'
Hi there,
Doing this would require a custom comments.php file in your child theme.
Here's an example of one: https://tommcfarlin.com/separate-comments-and-pingbacks/
So you would put that comments.php file into your child theme, and it will overwrite the theme's comments.php file.
Let me know if you have any trouble :)
Thank you. I did follow the instructions of the example but it didn't work. I replaced the comments.php and put the two other php files in the same folder. The result is that only both h3 headlines are being displayed including the number of comments. No comments, no pingbacks and no number of pingbacks are being displayed.
Any idea what to do?
Hmm, this is pretty tough.
Give this comments.php file a try: https://gist.github.com/generatepress/4b1cf22a773cdc0f06c5
This is great! Works fine.
Thanks a lot Tom.
Best'
No problem :)
One more thing…
I want to have the pingback h3 headline only been shown if there are pingbacks. I tried this one but it doesn't work
if ( ! empty($comments_by_type['pings']) ) :
How do I check for if the are pingbacks?
Hmm, good question..
You can try adding a function like this:
function generate_post_has( $type, $post_id ) {
$comments = get_comments('status=approve&type=' . $type . '&post_id=' . $post_id );
$comments = separate_comments( $comments );
return 0 < count( $comments[ $type ] );
}
Then use this conditional around your trackback heading:
if ( generate_post_has( 'pings', $post->ID ) ) {
?>
<h3>Pingbacks and Trackbacks</h3>
<?php
}
excellent!
Thank you Tom
You're welcome :)
