Here's the code in question. It started looking like this:
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
I removed the & signs per other posts I have seen but it didn't help.
$comments_by_type = separate_comments(get_comments('status=approve post_id=' . $id));
return count($comments_by_type['comment']);
Here's the code in question. It started looking like this:
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
I removed the & signs per other posts I have seen but it didn't help.
$comments_by_type = separate_comments(get_comments('status=approve post_id=' . $id));
return count($comments_by_type['comment']);
The issue is caused by the arguments for separate_comments
being passed by-reference. Source: function separate_comments(&$comments)
. This means passing a function as an argument is restricted.
To resolve the issue you need to assign the get_comments
function results to a variable.
$comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments($comments);
return count($comments_by_type['comment']);
separate_comments
are being passed by-reference asfunction separate_comments(&$comments)
. You would need to assignget_comments
to a variable.$comments = get_comments('status=approve&post_id=' . $id);
Thenseparate_comments($comments);
– Will B. Commented Nov 1, 2018 at 17:25separate_comments
as you never defined$comments
, please see my answer. – Will B. Commented Nov 1, 2018 at 19:11