0

I'm very new to the developing world and have been, with the help of Youtube, been learning to design Wordpress themes with HTML, CSS and PHP. I am using MAMP to locally host my wordpress site. When I make an error, like forgetting to close my PHP tag, and I refresh my site, all I see is "the site is experiencing technical difficulties" and I'm not sure where I can check my syntax or other errors. Any suggestions?

0

2 Answers 2

0

When developing it's a good idea to enable debugging, as described in this article in the developer handbook.

Essentially in wp-config.php you want to define the WP_DEBUG as true.

define( 'WP_DEBUG', true );

This will cause WordPress to output more errors and warnings to the screen, which can help finding issues. You can also log these to wp-content/debug.log by setting WP_DEBUG_LOG to true:

define( 'WP_DEBUG_LOG', true );

In 5.2+ you might also want to disable the 'fatal error handler', which is responsible for the screen that's displaying the "the site is experiencing technical difficulties" message.

define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );

Just keep in mind that none of these should be turned on in a live environment.

0

Your code needs syntax sanity-checking before you upload it. There are Wordpress IDEs which may help, but I haven't used them. I don't think there is any way for Wordpress to check your code if that code has php errors that will halt execution cold. When you're writing PHP in a template, a plugin, functions.php or other theme files, it must be unambiguous and even if wrong, it has to fail gracefully enough for an error handler to send a message to a log file. I see the error you describe anytime I leave out a ";" or use "=" when I mean "==".

Are you writing a theme from scratch, or starting with a base theme and making changes? I'd highly recommend the latter. Edit just a few lines, use a language sensitive editor or IDE, then see if your change works. If you get the "the site is experiencing technical difficulties" message, look first for obvious syntax bugs. If it all looks good, make sure you haven't mixed up how you're using your quotes ... ' " and ` all have different behaviors. So many other things. I'm a year into doing more and more coding on my site, but I still see that message just about every day.

Most important suggestion ... the less you've changed since you last saw it work, the fewer lines you have to stare at. Next most important suggestion, if you can't find the problem, don't start flailing and changing things that worked before. Look up what you thought was obviously correct first, because your case could be a little different.

1
  • Thanks man! This made me feel a lot better about my efforts. Commented Jun 22, 2019 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.