WordPress.org

Ready to get started?Download WordPress

Forums

Visual placement of comments (3 posts)

  1. marc0047
    Member
    Posted 8 years ago #

    For my comments section of my blog, I'm only displaying pings and trackbacks. However, rather than place them within the permalink's main body, I'd very much like to place it the side column.

    Unfortunately, the comments template tags only work *within* the loop, and the side column falls outside the loop. Is there a way around this?

    Thanks,
    marc

  2. tomhanna
    Member
    Posted 8 years ago #

    Here's how one theme (Identification Bands by Neuro) does something similar with comments. I don't know what you'd need to change exactly to show trackbacks and pings instead, but it shouldn't be too tough.

    <?php
    global $comment;

    if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved='1' ORDER BY comment_date_gmt
    DESC LIMIT 5") ) :
    ?>

    <h2 class='coltitle'><?php _e('Last Comments'); ?></h2>
    <ul>
    <li>
    <ul>
    <?php
    foreach ($comments as $comment) {
    echo '<li>' . sprintf('%s <span style="text-transform: lowercase;">on </span>%s', get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
    echo '</li>';
    }

    ?>
    </ul>
    </li>
    </ul>
    <?php endif; ?>

  3. marc0047
    Member
    Posted 8 years ago #

    Thanks for the tip.

    I also tried calling the "sidebar" in the default Kubrick style and activated the comments, and that worked too. So comments does in fact work outside the loop.

    The most important element that *must* be called is the 'comments_template()' function, and everything will work fine.

    If the function is not called, it's like turning the light switch off.

Topic Closed

This topic has been closed to new replies.

About this Topic