• Hi all,

    I’m trying to find if it’s possible to change the way comments are viewed on my wp site. I’d rather see a list of comments under the posts in my main thread then have people navigate away to a specific comments page…

    Is this possible and if so, can anyone help out with the coding that would be involved?

    Simplicity is the key to my site and I’d like the comments to elegantly sit under the post itself…

    Cheers,
    JB

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes it is possible, and quite easy.

    Comment count –
    <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>

    Show comments – see the codex here for more information
    <?php get_comment($id, $output); ?>

    Thread Starter blurredv

    (@blurredv)

    Thanks duck_boy!

    So do I just add this code to the ‘comments.php’ page or do I need to replace code? Not 100%.

    Cheers,
    JB

    If you want your comments displayed on each post you would need to add it to single.php, inside The Loop (look it up if you are not sure what The Loop is). You will need to amend slightly so that the $id and $output variables hold the correct information.

    You will then need to add a little code to display what you want. For example, the following would display the Author and then the Comment and should hopefully get you going –

    $comments_ids = $wpdb->get_results("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID='".the_id());
    
    foreach($comment_ids as $comment_id){
    	<?php $comment = get_comment($comment_id); ?>
    	<h3>Comment by <?php echo $comment->comment_author; ?></h3>
    	<p><?php echo $comment->comment_content; ?></p>

    }`

    Cant the post id be extracted without another db query ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Comments in Main Thread’ is closed to new replies.