Title: PHP Header Warnings on Shortcodes
Last modified: April 12, 2023

---

# PHP Header Warnings on Shortcodes

 *  Resolved [euro11](https://wordpress.org/support/users/euro11/)
 * (@euro11)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-header-warnings-on-shortcodes/)
 * It seems like every shortcode that I use in Code Snippets ends up getting the
   following PHP warning:
 * “Cannot modify header information. headers already sent in /wp-includes/load.
   php on line 300”.
 * I used the default HTML sample shortcode from Code Snippets:
 *     ```wp-block-code
       add_shortcode( 'shortcode_name', function () {
       	$out = '<p>write your HTML shortcode content here</p>';	
       return $out;} );
       ```
   
 * And also another shortcode for search bar:
 *     ```wp-block-code
       add_shortcode('wpsearch', 'get_search_form');
       ```
   
 * Both of them throw PHP Warnings in the error log. should I ignore it since it’s
   just a warning ?!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-header-warnings-on-shortcodes/#post-16647842)
 * The problem here is that, by default, `get_search_form` will _display_ content
   instead of _returning_ it, as in your first example.
 * You can rewrite the second shortcode to return content instead:
 *     ```wp-block-code
       add_shortcode( 'wpsearch', function () {
       	return get_search_form( [ 'echo' => false ] );
       } );
       ```
   
 *  Thread Starter [euro11](https://wordpress.org/support/users/euro11/)
 * (@euro11)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-header-warnings-on-shortcodes/#post-16650577)
 * It wasn’t the shortcode or the plugin. I should have triple checked before posting.
   by checking the line 300 of load.php, I realized it was my custom .maintenance
   file that was causing the issue. thanks for your help anyway.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Header Warnings on Shortcodes’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [euro11](https://wordpress.org/support/users/euro11/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/php-header-warnings-on-shortcodes/#post-16650577)
 * Status: resolved