0

I have a feeling that my code is causing the following error:

PHP Warning: Cannot modify header information - headers already sent by (output started at /public_html/MY-WEBSITE/wp-content/plugins/SOME-OTHER-PLUGIN/init.php:2) in /public_html/MY-WEBSITE/wp-includes/rest-api/class-wp-rest-server.php on line 1655

My code is below and it pretty much outputs some custom post content:

add_action('wp_footer', 'My_Class::output_custom', 9999);

public static function output_custom() {
  $post_content = self::get_custom();
  echo do_shortcode( $post_content );
}

I have a feeling that the SOME-OTHER-PLUGIN is also reacting to wp_footer and doesn't like that my plugin is echo'ing. Do you think my echo is the possible cause of the above issue and is there a alternative function I can use instead of echo?

1
  • 2
    The "Cannot modify headers" usually indicates that something's rendering output before all the headers have been sent. The wp_footer action should be safe for you to output content. Does the error go away if you comment out the echo statement? Have you checked with the other plugin's support about this warning? – Pat J Feb 16 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.