• I’m writing an application which uses shortcodes to display sections of information on the page. This information is retrieved from an API, and could possibly return an exception, there could be a connection error for example. Usually when I throw an exception in PHP, the page will be returned with a 500 (server error) HTTP status code to the browser, however when I do this in my WordPress shortcode function, it returns a 200 (success). This means I can’t redirect the browser to a generic 500 error page.

    Upon close inspection, if I throw an exception in the template file before wp_head(); is called, I do get a 500 back, but if I do it afterwards, it returns a 200 as if nothing is wrong.

    Could it be a plugin doing this or is this natural WordPress behavior?

  • The topic ‘Throwing exceptions, (e.g. in shortcode or template) doesn't return 500 error’ is closed to new replies.