Skip to content

Instantly share code, notes, and snippets.

@baczoni
Created April 24, 2012 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baczoni/2480899 to your computer and use it in GitHub Desktop.
Save baczoni/2480899 to your computer and use it in GitHub Desktop.
Wordpress: Separate comments from trackbacks
<?php
// Find:
foreach ($comments as $comment) :
// Comments are displayed here
endforeach;
?>
<?php
// And replace with:
?>
<ul class="commentlist">
<?php //Displays comments only
foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
<li>//Comment code goes here</li>
<?php }
endforeach;
?>
</ul>
<ul>
<?php //Displays trackbacks only
foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php }
endforeach;
?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment