WordPress.org

Support

Support » How-To and Troubleshooting » functions.php Fatal error: Only variables can be passed by reference

functions.php Fatal error: Only variables can be passed by reference

  • Hello,
    i get the error
    Fatal error: Only variables can be passed by reference in /path/to/theme/functions.php on line 10

    Here a the code from line 1 to 14

    <?php
    function ping_count() {
    global $id;
    $comments_by_type = &separate_comments(get_comments('post_id=' . $id));
    return count($comments_by_type['pings']);
    }
    
    function comment_count() {
    global $id;
    $comments_by_type = &separate_comments(get_comments('post_id=' . $id));
    return count($comments_by_type['comment']);
    }
    add_filter('get_comments_number', 'comment_count', 0);
    ?>

    Where a the error?

    Thanks for help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    @esmi

    Forum Moderator

    $comments_by_type = &separate_comments(get_comments('post_id=' . $id));

    That’s referencing a non-native function so I’ve no idea how it’s supposed to work but you could try changing it to:

    $comments_by_type = separate_comments(get_comments('post_id=' . $id));

    Thanks for you help but that help not.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘functions.php Fatal error: Only variables can be passed by reference’ is closed to new replies.
Skip to toolbar