I’m trying to write a function that will allow me more control over the display of comments on a post page. However I’m confused about how to set it up so WordPress can use it. right now I get the following error:
Warning: call_user_func() expects parameter 1 to be a valid callback,
function ‘custom_comments()’ not found or invalid function name in
/Users/Brent/Desktop/Web Design/WP
Playground/wordpress/wp-includes/comment-template.php on line 1711
Here is the call to the function:
<div class="comment-list">
<?php
wp_list_comments('type=comment&callback=custom_comments()');
?>
</div><!-- .comment-list -->
And here is what that section of my functions.php file looks like:
add_action('load_comments', 'custom_comments');
function custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div class="comment-intro">
<em>commented on</em>
<a class="comment-permalink" href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)) ?>"><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></a>
<em>by</em>
<?php printf(__('%s'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><php _e('Your comment is awaiting moderation.') ?></em><br />
<?php endif; ?>
<?php comment_text(); ?>
<div class="reply">
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php } ?>
Could anyone tell me what I’m doing wrong here to get this error? I know from my research on this issue that sometimes you need to remove_action from another function that may be conflicting with this function, but I’m not even sure I’m calling this function correctly. Please help, I’m having a hard time finding good resources on how to use a custom comment function.
This is the only good resource I’ve found so I’ve been following this but it doesn’t say anything about the errors: Custom Comments HTML Output
When I googled the error I found this page slightly helpful, but I haven’t been able to identify the culprit function: wordpress.org
I’ve checked out a few other questions on here but they mostly seem to be asking about other specific problems. Help is greatly GREATLY appreciated!
wp_list_comments 1st argument is an array not a string, so your call should be