The Cannot modify header
error is actually caused by the first error, as the error is being printed on the page invoking a header, therefore any code coming after that trying to modify the header will produce the Cannot modify header
error.
As to the Undefined index: action
error, apparently the theme author assumes that the action
parameter of the superglobal $_GET
will always be set on the post page (ie. the URL should have ...post.php?action=something
at all times), which appears to be true in most cases, but a smart coder will always prepare for the worst, and check the existence of variables (though it would be interesting to know the full URL you see displayed when you get this error).
To avoid this, they’d need to check whether it exists at all using isset($_GET['action'])
(alternatively array_key_exists('action', $_GET
), and do the same on $_GET['post']
, also assumed to always be set, so the full if
condition would look something like this:
// ...
if ( 'post.php' === $pagenow && isset($_GET['action']) && 'edit' === $_GET['action'] && isset($_GET['post']) && is_numeric($_GET['post'])) {
// ...
}
You have several ways to introduce this solution:
-
The recommended option would be to contact the theme owner and ask them to address this. While waiting, you could also do…
-
If you decide to update the original theme, and later on want to upgrade the theme, prepare yourself having to do this again.
-
Alternatively you could remove the function (
remove_action
) in yourfunctions.php
in your child theme (assuming you’re using one) and adding the correct one to replace it using the same hook that was used inadd_action
of the original theme (in this case it is'bedford_cmb1_to_cmb2_post_meta'
).