I am getting this error for number of comments in wordpress post meta. The error remains even after remover ‘&’ from seperate_comments function.
function shizzo_comments_number( $count )
{
if ( !is_admin() ) {
global $id;
$comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
return count( $comments_by_type['comment'] );
} else {
return $count;
}
}
This message appears after turning on the Wp_debug and reviewer asked me to correct this.
You didn’t say what the message is so one can only guess.
How about if you replace
'status=approve&post_id='
with
'status=approve&post_id='
It shows error for following line:-
$comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
The solution you provided above didn’t work.
It’s referring to the & in that line, to get rif of that error you’ll need to remove that &
That’s what I was thinking. Going by the topic’s title
Strict standards: Only variables should be passed by reference
But if
The error remains even after remover ‘&’ from seperate_comments function.
I see no other “&” so I’m guessing the error message is different then?
Please excuse me for butting in but I was intrigued.
// Replace this:
$comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
// With this:
$comments_by_type = separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
Reason is that separate_comments(…) is a function and not a variable.
Exactly, so I would expect a “function undefined” or “parameter not found” type of error, if any, after it’s being removed.
@Orahmax is this part of a plug-in?
Your calling a fuction as a reference, you can’t do that in php. Were you trying to use error supression? Error suppression is also not advisible. Remove the & before the function call and it should work.
Finally, Fixed it!
$get_comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments( $get_comments );
You can see the difference here - https://themes.trac.wordpress.org/changeset?old_path=/haunted/1.04&new_path=/haunted/1.05
Theme Reviewer suggested me to look at this theme as the author resolved this issue.
oddz
January 7, 2015, 5:09am
12
Once again the personification of the quality of work produced within the Wordpress ecosystem. Just music to my ears.
system
Closed
April 8, 2015, 12:16pm
13
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.