Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End get wordpress comments

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35048
    cybershot
    Participant

    I am trying to get post specific comments. The code below does return comments, but it gets them all. How can I get those specific to the post?




    //$args = array('order' => 'ASC');
    $comments = get_comments('$post_id');
    foreach($comments as $comment) :
    ?>


    • comment_content); ?>





    #90281
    TheDoc
    Member

    Well, I would probably just use the code from the twentyeleven theme and use the have_comments loop. But, if you want to go this way, you could grab the post ID first, then put it into get_comments. Something like this:

    $current = $post->id;

    Then you can use:

    get_comments($current);
    #90283
    dclardy64
    Member

    Your code does not pass the correct parameter to the function. You care just getting all comments because of that.

    
    //$args = array('order' => 'ASC');
    $comments = get_comments('$post->id');
    foreach($comments as $comment) :
    ?>


    • comment_content); ?>



    I changed the ‘$post_id to $post->id that should fix the error.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.