WP_Comment_Query with 5 top level comments per page?

Updated

The hierarchical parameter controls whether to include comment descendants in the comments results.

From the inline docs we have that it accepts the following values:

  • 'threaded' returns a tree, with each comment’s children stored in a children property on the WP_Comment object.
  • 'flat' returns a flat array of found comments plus their children.
  • false to leave out descendants.

It also says that

The parameter is ignored (forced to false) when $fields is ‘ids’
or ‘counts’.

Both the 'threaded' and 'flat' options makes use of the WP_Comment_Query::fill_descendants() method:

Instead of calling get_children() separately on each child comment, we
do a single set of queries to fetch the descendant trees for all
matched top-level comments.

but the threaded option has additional snippet that uses the add_child() method of the WP_Comment object to construct the children property.


As @Swen mentioned in comments, one should use the 'threaded' option.

It looks like the true value would in fact give the same as the 'flat' option.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)