Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have three pages, and I want them all to display the comments form from a post with id=343. What code would I use within the pages to make that happen?

Here is what I've tried:

<?php
$id=343; // sample, I get the latest post id of a particular category
comments_template();
?>

But that doesn't work, it just shows the blank comment form from the page. Any thoughts / suggestions?

share|improve this question

2 Answers 2

use this if you want to show comment on a specific post is_single('1')

share|improve this answer
    
This is not what I'm trying to do. Lets say I have three pages, and I want them all to display the comments form from post (id=343). What code would I use within the pages to make that happen? –  themerlinproject May 1 '12 at 7:19
    
you can do this by giving or operator like this if(is_single(121) || is_single(5)) –  Jassi Oberoi May 1 '12 at 7:44

Use get_comments() and pass the post ID as parameter:

$comments = get_comments(
    array (
        'post_id' => 343
    ) 
);

foreach ( $comments as $comment )
{
    // Just to give you an idea of the available data.
    // You will probably do something better with it. :)
    var_export( $comment );
}

Related: Bug #20572 ($post_id not passed to comment_open() from comment_form()) was fixed just two days ago.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.