WordPress.org

Ready to get started?Download WordPress

Forums

functions.php Fatal error: Only variables can be passed by reference (3 posts)

  1. Yoschi
    Member
    Posted 4 years ago #

    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.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    $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));

  3. Yoschi
    Member
    Posted 4 years ago #

    Thanks for you help but that help not.

Topic Closed

This topic has been closed to new replies.

About this Topic