Support » Themes and Templates » how to seperate comments from trackbacks/pings

  • Resolved fifthhouse

    (@fifthhouse)


    My theme treats comments, trackbacks and pinbacks all the same, listing them in my comments. Does someone know, iss there a way to separate these, and is this complicated?

Viewing 3 replies - 1 through 3 (of 3 total)
  • benoist

    (@benoist)

    Change your comments.php with this :

    <?php // Do not delete these lines
    if (‘comments.php’ == basename($_SERVER[‘SCRIPT_FILENAME’]))
    die (‘Merci de ne pas lancer cette page directement.’);

    if (!empty($post->post_password)) { // if there’s a password
    if ($_COOKIE[‘wp-postpass_’ . COOKIEHASH] != $post->post_password) { // and it doesn’t match the cookie
    ?>
    <p class=”nocomments”>Cet article est protégé par un mot de passe. Entrez ce mot de passe pour voir les commentaires.</p>
    <?php
    return;
    }
    }

    function comments_human_number( $zero = false, $one = false, $more = false, $deprecated = ”, $number = 0 ) {
    if ( $number > 1 )
    $output = str_replace(‘%’, $number, ( false === $more ) ? __(‘% Comments’) : $more);
    elseif ( $number == 0 )
    $output = ( false === $zero ) ? __(‘No Comments’) : $zero;
    else // must be one
    $output = ( false === $one ) ? __(‘1 Comment’) : $one;

    echo apply_filters(‘comments_number’, $output, $number);
    }

    function comments_trackback_number( $zero = false, $one = false, $more = false, $deprecated = ”, $number = 0 ) {
    if ( $number > 1 )
    $output = str_replace(‘%’, $number, ( false === $more ) ? __(‘% trackbacks’) : $more);
    elseif ( $number == 0 )
    $output = ( false === $zero ) ? __(‘No trackback’) : $zero;
    else // must be one
    $output = ( false === $one ) ? __(‘1 trackback’) : $one;

    echo apply_filters(‘comments_number’, $output, $number);
    }

    /* This variable is for alternating comment background */
    $oddcomment = ‘class=”alt” ‘;
    ?>

    <!– You can start editing here. –>
    <?php if ($comments) : ?>

    <?php
    $trackbacks_counter = $comments_human_counter = 0;
    foreach ( (array) $comments as $comment ) :
    $type = get_comment_type();
    if ( $type != ‘comment’ ) {
    $trackbacks[] = $comment;
    $trackbacks_counter++;
    } else {
    $comments_human[] = $comment;
    $comments_human_counter++;
    }
    endforeach;
    ?>

    <h3 id=”comments”><?php comments_human_number(‘Aucun commentaire’, ‘Un commentaire’, ‘% commentaires’, ”, $comments_human_counter );?> pour “<?php the_title(); ?>”</h3>
    <ol class=”commentlist”>
    <?php foreach ( (array) $comments_human as $comment ) : ?>
    <li <?php echo $oddcomment; ?>id=”comment-<?php comment_ID() ?>”>
    <cite><?php comment_author_link() ?></cite> dit :
    <?php if ($comment->comment_approved == ‘0’) : ?>
    Votre commentaire est en attente de modération.
    <?php endif; ?>

    <small class=”commentmetadata”>” title=””><?php comment_date(‘j F Y’) ?> à <?php comment_time() ?> <?php edit_comment_link(‘Editer’,’– ‘,”); ?></small>
    <?php comment_text() ?>

    <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? ‘class=”alt” ‘ : ”; ?>
    <?php endforeach; /* end for each comment */ ?>

    <h3 id=”trackbacks”><?php comments_trackback_number(‘Aucun trackback’, ‘Un trackback’, ‘% trackbacks’, ”, $trackbacks_counter );?></h3>
    <ol class=”trackbacklist”>
    <?php foreach ( (array) $trackbacks as $comment ) : ?>
    <li <?php echo $oddcomment; ?>id=”comment-<?php comment_ID() ?>”><?php comment_author_link() ?>
    <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? ‘class=”alt” ‘ : ”; ?>
    <?php endforeach; /* end for each trackback */ ?>

    <?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”>Les commentaires sont fermés. </p>
    <?php endif; ?>
    <?php endif; ?>

    <?php if (‘open’ == $post->comment_status) : ?>
    <h3 id=”respond”>Laisser un commentaire </h3>
    <?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
    <p>Vous devez être /wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>”>connecté pour publier un commentaire.</p>
    <?php else : ?>
    <form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>
    <?php if ( $user_ID ) : ?>
    <p>Connecté en tant que /wp-admin/profile.php”><?php echo $user_identity; ?>. /wp-login.php?action=logout” title=”Se déconnecter du site.”>Se déconnecter »</p>
    <?php else : ?>
    <p><input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”22″ tabindex=”1″ />
    <label for=”author”><small>Nom <?php if ($req) echo “(obligatoire)”; ?></small></label>
    </p>
    <p><input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”22″ tabindex=”2″ />
    <label for=”email”><small>Adresse e-mail (ne sera pas publié) <?php if ($req) echo “(obligatoire)”; ?></small></label>
    </p>
    <p><input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”22″ tabindex=”3″ />
    <label for=”url”><small>Site Web</small></label>
    </p>
    <?php endif; ?>
    <!–<p><small>XHTML: Vous pouvez utiliser ces tags: <?php echo allowed_tags(); ?></small></p>–>
    <p><textarea name=”comment” id=”comment” cols=”100%” rows=”10″ tabindex=”4″></textarea></p>
    <p><input name=”submit” type=”submit” id=”submit” tabindex=”5″ value=”Dites-le !” />
    <input type=”hidden” name=”comment_post_ID” value=”<?php echo $id; ?>” />
    </p>
    <?php do_action(‘comment_form’, $post->ID); ?>
    </form>

    <?php endif; // If registration required and not logged in ?>
    <?php endif; // if you delete this the sky will fall on your head ?>

    benoist

    (@benoist)

    This is my french version, you can easily translate in your language

    Thread Starter fifthhouse

    (@fifthhouse)

    Thanks very much for this. I’m going to hold off right now because I don’t want to lost the formatting of my comments. Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to seperate comments from trackbacks/pings’ is closed to new replies.