This error occurs because the session_start()
function is creating a PHP session, which interferes with REST API and loopback requests in WordPress. To resolve this:
- Locate the
session_start()
code
Search your theme or active plugins for thesession_start()
function. It may be in the theme’sfunctions.php
file or in a custom plugin. - Add
session_write_close()
aftersession_start()
Ensuresession_write_close()
is called after eachsession_start()
call, before making any HTTP requests. This will close the session and allow the REST API to work correctly. For example: - Use the
init
hook in WordPress
Ifsession_start()
needs to be infunctions.php
, make sure to wrap it in theinit
hook and usesession_write_close()
like this:
Leave A Comment