I'm building a simple event calendar, and I want to show a WP error page, for example when users try to edit an event that does not exist, see the attached picture (which is when you try to edit a post that doesn't exist)

What is the correct Wordpress way to do this? I tried throwing errors and trigger_error() as I thought WP might handle the latter, but this isn't how it works.

Note: I'm not trying to add a notice to my page, I want to show the WP error page.

enter image description here

  • Ok, my own closest answer so far: wp_die() Jan 7, 2016 at 14:28

1 Answer 1


wp_die() See the codex for full usage details:


You can even include html in the message field if you want to.

  • I'm trying that, but WP displays sidebar, navigation bar and my error message in the top left corner. Title is being ignored, and it doesn't show back link, which I turned on in the args... Jan 7, 2016 at 14:37
  • Ok, I'm guessing I need to attempt handling the error much earlier. Jan 7, 2016 at 14:40
  • Ok, this semi-works, but is not styled like the original WordPress error in my question. I'm calling wp_die() from within an admin page callback for my plugin, and the sidebar and navigation bar has already been output. So technically speaking my wp_die is too late... Jan 7, 2016 at 15:00
  • Why do you want to exclude the navigation bar(s)? You shouldn't be trapping the user on an error page. Also, the args are an associative array not just the argument values; many people miss that.
    – C C
    Jan 7, 2016 at 16:23
  • I'm was simply trying to stick with Wordpress' consistency. If you for example try to edit a post/page that does not exist, you simply get a "chromeless" error message stating the item you edit does not exist. However, I've changed my page to simply show the error message formatted as a WP notice with a back link, and works fine now. I'm not going to fuss about this too much. Jan 8, 2016 at 9:15

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.