WordPress.org

Ready to get started?Download WordPress

Forums

Trackback Comment Type is 'comment' ? (3 posts)

  1. dallasmoore
    Member
    Posted 3 years ago #

    I'm using a self-made 'recent comments' plugin, which is working fine. My only problem is getting it to show only comments and not trackbacks. I have used the get_comment_type() function to display only 'comments' but it turns out, any "trackbacks" from my own site are showing up as comments. Why would get_comment_type() = comments for these?

    When I say trackbacks (the terms confuse me), I mean we have linked to one post from another and the 'comment' is showing up as [...] however it isn't showing up in the comments below the post. I'm baffled by this so if you have any ideas at all, please let me know. The site is at http://www.thinkpadtoday.com and you will see the comments widget halfway down in the sidebar on the right, which is currently showing the trackback.

    Thanks!

    Dallas

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    it's a problem with self pings? If so I use this handy code:

    // NO SELF PINGS
    function no_self_ping( &$links ) {
    	$home = get_option( 'home' );
    	foreach ( $links as $l => $link )
    		if ( 0 === strpos( $link, $home ) )
    			unset($links[$l]);
    	}
    add_action( 'pre_ping', 'no_self_ping' );

    in functions.php to stop all self-pings

    How are you listing the comments?

  3. dallasmoore
    Member
    Posted 3 years ago #

    I don't want to stop self-pings, I just don't want them to show up when I call the comments in my widget. If I wanted to stop, I would just delete them instead of approving. I am using this code

    <?php $thinkfan_comments = get_comments( array('number'    => 5,'status'    => 'approve') );
              foreach($thinkfan_comments as $comment) :
              $comment_type = get_comment_type();
              if($comment_type == 'comment') {
                  echo('<div class="post"><p class="comment">'.substr($comment->comment_content, 0, $instance['limit']).'...<span class="commentmore"><a href="'.get_permalink($comment->comment_post_ID).'">Join The Conversation</a></span></p>'.get_avatar( $comment->comment_author_email ).'<p class="thinksidedate"><em>by '.$comment->comment_author.'</em></p></div>');
              } else { $trackback = true; } /* End of is_comment statement */
              endforeach; ?>

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic