How do I display trackbacks (the link and the date) outside of the twentyeleven comment loop?
The function below is from the twentyeleven functions.php file. I’m using the standard comments.php file from twentyeleven, and the trackbacks are shown under the comments when using <?php comments_template( '', true ); ?>
in a template file. I can delete that, but while keeping the normal comments display, how do I display pings in other areas of a template file all by themselves?
(Yes, I’m using a child theme.)
if ( ! function_exists( 'twentyeleven_comment' ) ) :
/**
* Template for comments and pingbacks.
*/
function twentyeleven_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
?>
Use the
type
param in the functionwp_list_comments()
.Copy the comments.php to your Child Theme. search for
wp_list_comments
. Find this:Change this with your Params, like this:
You can also use the param value
pings
, there have include trackback and pingback; maybe you will only show pingback, then use the valuepingback
for thevalue
param. Also you can change the markup of html to more difference in the output.If you will separate the pingback and comments in seperate areas, then like this.
Now a screenshot of the results to the code above:
At last, the param
type
and his possibilities:$type
– (string) (optional)The type of comment(s) to display. Can be
'all'
,'comment'
,'trackback'
,'pingback'
, or'pings'
.'pings'
is'trackback'
and'pingback'
together.Default:
'all'
In your comments.php (child theme) you can use something like that:
And then do the same thing for pings…