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.
array (size=10)
  'comment 0' =>
    array (size=2)
      'comment_id' => string '22' (length=2)
      'parent_of' => string '0' (length=1)
  'comment 1' =>
    array (size=2)
      'comment_id' => string '23' (length=2)
      'parent_of' => string '0' (length=1)
  'comment 2' =>
    array (size=2)
      'comment_id' => string '24' (length=2)
      'parent_of' => string '0' (length=1)
  'comment 3' =>
    array (size=2)
      'comment_id' => string '25' (length=2)
      'parent_of' => string '0' (length=1)
  'comment 4' =>
    array (size=2)
      'comment_id' => string '26' (length=2)
      'parent_of' => string '24' (length=2)
  'comment 5' =>
    array (size=2)
      'comment_id' => string '27' (length=2)
      'parent_of' => string '22' (length=2)
  'comment 6' =>
    array (size=2)
      'comment_id' => string '28' (length=2)
      'parent_of' => string '0' (length=1)
  'comment 7' =>
    array (size=2)
      'comment_id' => string '29' (length=2)
      'parent_of' => string '25' (length=2)
  'comment 8' =>
    array (size=2)
      'comment_id' => string '30' (length=2)
      'parent_of' => string '29' (length=2)
  'comment 9' =>
    array (size=2)
      'comment_id' => string '31' (length=2)
      'parent_of' => string '27' (length=2)

this is a var_dump of comment_ID and comment_parent.

main output: 22, 23, 24, 25, 26, 27, 28, 29, 30, 31

right order: 22 -> 27 -> 31, 23, 24 -> 26, 25 -> 29 -> 30, 28

share|improve this question
    
What code are you using the get the comments? –  Steven Sep 7 '12 at 10:58
add comment

1 Answer

Short of building it yourself, you don't. WordPress doesn't have a way to get a nested array of comments like that. Instead, it gets all the comments to be displayed, then uses a class called a "walker" to display them.

The Walker_Comment class is built on top of the generic Walker class. The Walker class implements the logic for traversing the array and using the parent field to determine the nesting, the Walker_Comment class implements the display characteristics, such as putting them into the proper HTML list items and such.

share|improve this answer
add comment

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.