1

Every time I read about making changes to wp-config.php, the advice given is to make changes before this line:

/* That's all, stop editing! Happy publishing. */

Why?

What is special about that line? Surely the parser is smart enough to handle stuff that comes after it? There of course IS stuff that comes after it.

1

There's no "parser" that needs to be "smart". It's just a PHP file that runs as part of WordPress loading. The reason you need to put edits before that line is because the line that comes after it is this:

require_once( ABSPATH . 'wp-settings.php' );

And this line basically loads all of WordPress. So any definitions added to wp-config.php after that line will be useless because WordPress has already finished loading.

You could conceivably add code between the comment from your question and this line, but the existing lines that are already there are checking for the existence of the ABSPATH constant, which means that if you wanted to redefine ABSPATH yourself, you need to do that before the "That's all" line.

So instead of saying something silly like "Define ABSPATH before this line, but it's ok to make other changes after this line, just make sure not to make them after the last line", it just suggests making all edits above those lines.

There's no good reason to ignore this comment.

  • Thanks, nice answer. Technically though there is a parser. :) – lonix Dec 4 '19 at 9:07
  • I meant one specific to wp-config.php. – Jacob Peattie Dec 4 '19 at 9:09
  • What would have been nicer would be if the custom config could be externalized to a separate file, which would be included by the main startup routines. That would avoid any race conditions. But the way it works is nonetheless ok, as long as one doesn't break the rule you explained above. – lonix Dec 4 '19 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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