Why is functions.php so touchy?

When ever I look at functions.php sideways my site crashes and I have to restore a backup manually via FTP.
Can someone please advise on the correct procedure for adding functions to this file (or its child theme counterpart) so it doesn’t keep spitting the dummy. There is no recovery from within wordpress admin, I’m always forced to overwrite the file on the server with a backup.

Any help appreciated.

Look at the grief the functions.php file causes green developers :worried:

My previous effort to understand the functions.php file

That is only one of many examples of very poor architectural decisions within WordPress than many other modern platforms do not suffer from – GO WORDPRESSS!!!

I’m not a WP user, so I’m guessing here, but I imagine it is just the same as any other php script, if you make any error in it, such as missing semicolon or bracket or whatever, you get an error on running it.
If the file is included in all pages, it crashes all pages on the site.
So you just need to be careful when editing, and if it goes wrong, check the error logs to pinpoint the error and debug.

2 Likes

Thanks Sam, Good advice!

You could consider putting the code in a plugin.

If you install a buggy plugin when you go to activate it WordPress will show a type of
“not activated. Error ____” message.

Seems the same safe guards should be in place for buggy themes.

But then, it is WordPress that gives non-devs the ability to live edit files.

Hand out loaded guns and eventually someone will shoot themselves in their foot. :footprints: :gun:

Exactly! :laughing:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.