While looping in get_comments() with these args:
$args = array(
'status' => 'approve',
'order' => 'DESC',
'number' => 5
);
I get more than five comments in the loop because of the nested comments.
I want to get the recent 5 comments even if they are parent or nested without disabling the nested feature from the admin panel.
For example: if the parent comment has 4 nested comments, i wanna just get it with it’s nested and counted as 5 instead of counting other parents.
You could use
array_slice
to return the first 5 items from the returned wordpress array of comments:Where
returnedCommentsArray
is the array of comments that is returned from your original wordpress call.