Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding functions.php to theme breaks site

  • Profile photo of Kevin Pine
    Kevin Pine
    Participant

    @kevinpine

    I am running WPMU 2.9.1.1 and BP 1.2.1. I have created a custom theme with just a few folders containing custom CSS, header.php, etc.

    When I put a copy of functions.php (with no customizations) in the theme folder the site will not render.

    Any ideas?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Profile photo of Andrea Rennick
    Andrea Rennick
    Participant

    @andrea_r

    black page = errors. There’s an error in your functions.php somewhere, I’d say.

    If you;re making a *child* theme, and you place a copy of the original theme’s functions’ file in your child theme, it WILL white-out your site. Because the child is *already* pulling the functions file.

    putting it in there is like putting it in there twice. hence the error. If you find your server error logs, I’m sure they’ll say “can’t redeclare and other duplicate function notices.

    Profile photo of Hugo
    Hugo
    Moderator

    @hnla

    I can confirm that as just now made the same error. functions.php was already called duplicating the file in child theme simply attempts to redclare an include – there is a require_once() in the original.

    Profile photo of Kevin Pine
    Kevin Pine
    Participant

    @kevinpine

    BP ignores other default files (like header.php) when you add a custom one to a theme, but apparently not the same for functions.php.

    What then is the best way to add php functions (like shortcode) to a child theme?

    Profile photo of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    You can add a functions file to a child theme it just can’t have the same functions as the default one.

    Profile photo of Kevin Pine
    Kevin Pine
    Participant

    @kevinpine

    Got it. Thanks, all!

    Profile photo of Kevin Pine
    Kevin Pine
    Participant

    @kevinpine

    Any php I add to functions.php in my theme breaks the page. Has anyone added custom functions as above?

    Yes. I’ve added functions to my child via functions.php. As long as the functions have unique names it won’t break anything. Something else must be wrong.

    Profile photo of stwc
    stwc
    Participant

    @stwc

    Yep, done this a lot, with BP and regular WP child theming. Should work fine if the code’s OK.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding functions.php to theme breaks site’ is closed to new replies.
Skip to toolbar