Skip to:
Content
Pages
Categories
Search
Top
Bottom

Cannot redeclare remove_counts


  • donalyza
    Participant

    @donalyza

    I was trying to follow the step by step guide to bbpress forum – part 3

    I copied the the function below and add it on line 9 of loop-single-forum.php file.

    function remove_counts() {
    $args['show_topic_count'] = false;
    $args['show_reply_count'] = false;
    $args['count_sep'] = '';
    return $args;
    }
    add_filter('bbp_before_list_forums_parse_args', 'remove_counts' );

    Then I ran my forum site and got this error.. I’m doing this locally to test.

    Fatal error: Cannot redeclare remove_counts() (previously declared in C:\wamp\www\wp\wp-content\themes\twentytwelve-child\bbpress\loop-single-forum.php:9) in C:\wamp\www\wp\wp-content\themes\twentytwelve-child\bbpress\loop-single-forum.php on line 14

Viewing 3 replies - 1 through 3 (of 3 total)
  • All function names need to be unique:

    See the WordPress Plugin Handbook for more details:

    Sanity Practices

    You can achieve this simple by prefixing the function names with your name: 🙂

    
    function donalyza_remove_counts() {
    $args['show_topic_count'] = false;
    $args['show_reply_count'] = false;
    $args['count_sep'] = '';
    return $args;
    }
    add_filter('bbp_before_list_forums_parse_args', 'donalyza_remove_counts' );
    

    Our codex articles will need to be updated to include prefixes so there are none of these conflict, suggestion might be bbp_codex_ so that way a hint is also given where the custom function may have originated from 😉


    donalyza
    Participant

    @donalyza

    Thanks Stephen @netweb for looking on to this.

    I really wish I could say it fixed the issue apparently I’m still getting the same error. 🙁

    ( ! ) Fatal error: Cannot redeclare bbp_codex_remove_counts() (previously declared in C:\wamp\www\wp\wp-content\themes\twentytwelve-child\bbpress\loop-single-forum.php:9) in C:\wamp\www\wp\wp-content\themes\twentytwelve-child\bbpress\loop-single-forum.php on line 14


    donalyza
    Participant

    @donalyza

    Nevermind. I fixed it.

    I placed the code on my child theme functions.php file rather stated on the guide on loop-single-forum.php.

    Cheers! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar