• Resolved euro11

    (@euro11)


    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:

    add_shortcode( 'shortcode_name', function () {
    	$out = '<p>write your HTML shortcode content here</p>';	
    return $out;} );

    And also another shortcode for search bar:

    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

    (@bungeshea)

    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:

    add_shortcode( 'wpsearch', function () {
    	return get_search_form( [ 'echo' => false ] );
    } );
    Thread Starter euro11

    (@euro11)

    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.