• I’ve taken over development of a WordPress system not originally done by me and have run into a couple of niggles. One is to do with problems with logging, which I’ve mentioned in a separate post. Another is that for some reason I cannot use custom functions which I have defined in functions.php in a page I am working on – when I make a request to the page it results in a 500 error. If I define the function within the page it works fine, but not if defined in functions.php (or in another file called with ‘require_once’). I would have hoped that the reason for the 500 error would be written to a log somewhere but it doesn’t appear in the nginx error.log, nor in /var/log/php7.4-fpm.log, so I don’t know where it is being written, if anywhere (maybe it would be written to debug.log, but that isn’t showin, as mentioned in my other post).

Viewing 5 replies - 1 through 5 (of 5 total)
  • Why the hosting’s own logging doesn’t contain something like that is impossible to judge here. You would have to contact the hoster’s support for that.

    But you can enable debugging in WordPress. Then WordPress creates its own logfile about the errors (if they are not too exceptional). See:

    Debugging in WordPress

    Thread Starter johnny2r

    (@johnny2r)

    As mentioned in the original post, the debug.log is not showing, for reasons unknown to me. This is on a VPS I have complete control over (root access).

    Then something is generally wrong with the server configuration. What it is is difficult to judge since we don’t know your environment. The best thing to do is to contact the hosting support or a community that supports the hosting system you use.

    Thread Starter johnny2r

    (@johnny2r)

    As mentioned in the previous post, there is no hosting company involved. This is a VPS I am in control of.

    Aside from the potential server config issues (which would be difficult to diagnose if there actually are any – at least without access anyways) if you are having trouble getting a custom function to load you could try adding it as a mu-plugin or in a custom plugin. In some cases it might be that another function on the site is hooking into the same hook (if that is what you are doing) and as such, you would need to use a higher priority for the “add action” if there is a conflict – which is not easy to tell if you can’t debug.

    Does the code work on a fresh WP installation or other sites?

    Without the code this would also be a big hard for us to provide any solution.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can’t use functions defined in functions.php’ is closed to new replies.