What is the difference between `wp_die()` and `die()` / `exit()` in WordPress?

WordPress Fundamental Hard

WordPress Fundamental — Hard

What is the difference between `wp_die()` and `die()` / `exit()` in WordPress?

Key points

  • wp_die() formats error messages in the WordPress admin theme
  • wp_die() sends correct HTTP headers
  • wp_die() handles AJAX requests returning JSON errors
  • die()/exit() terminates immediately without WordPress context

Ready to go further?

Related questions