• Starting with a basic ‘blankslate’ template and woocommerce, when I add a secondary-widget-area in my themes function.php file, the info in the woocommerce ‘cart widget’ fails to update or display cart contents and random clicks on the site cause following error. . . . . .

    “Warning: Cannot modify header information – headers already sent by (output started at /home/somethinhosting/public_html/silveradotruckaccessories.com/wp-content/themes/blankslate/functions.php:1) in /home/somethinhosting/public_html/silveradotruckaccessories.com/wp-includes/pluggable.php on line 1207”

    note:It works flawlessly on my local Server, only running into this issue after i upload the function.php to the live server

    View it here at: https://www.silveradota.com

    https://www.ads-software.com/plugins/woocommerce/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter SU Mike

    (@su-mike)

    add_action( ‘widgets_init’, ‘SilveradoTA_widgets_init’ );
    function SilveradoTA_widgets_init()
    {
    register_sidebar( array (
    ‘name’ => __( ‘Sidebar Widget Area’, ‘SilveradoTA’ ),
    ‘id’ => ‘primary-widget-area’,
    ‘before_widget’ => ‘<li id=”%1$s” class=”widget-container %2$s”>’,
    ‘after_widget’ => “”,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’,
    ) );
    register_sidebar( array (
    ‘name’ => __( ‘Secondary Widget Area’, ‘SilveradoTA’ ),
    ‘id’ => ‘secondary-widget-area’,
    ‘before_widget’ => ‘<li id=”%1$s” class=”widget-container %2$s”>’,
    ‘after_widget’ => “”,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’,
    ) );
    }

    Plugin Contributor Mike Jolley

    (@mikejolley)

    See if there is any whitespace or invalid chars in functions.php line 1.

    Thread Starter SU Mike

    (@su-mike)

    <?php
    add_action( ‘after_setup_theme’, ‘SilveradoTA_setup’ );
    function SilveradoTA_setup()
    {
    load_theme_textdomain( ‘SilveradoTA’, get_template_directory() . ‘/languages’ );

    That’s how it starts, I’m starting with a clean ‘blankslate’ template and basic css and the only thing I’m adding to the function.php is the secondary register-sidebar( array(. . . . . . .It works on my local server just fine without a problem so I don’t know what to chase.

    Thread Starter SU Mike

    (@su-mike)

    also to mention, I simply cannot erase the secondary_widget code in the function.php file and have it go back to normal even though I reverted it to where i started, I’m having to overwrite the online function.php file with a local copy in order to make the error go away, I don’t get that.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Can you upload the entire file somewhere for us?

    Thread Starter SU Mike

    (@su-mike)

    ?<?php
    add_action( ‘after_setup_theme’, ‘blankslate_setup’ );
    function blankslate_setup()
    {
    load_theme_textdomain( ‘blankslate’, get_template_directory() . ‘/languages’ );
    add_theme_support( ‘automatic-feed-links’ );
    add_theme_support( ‘post-thumbnails’ );
    global $content_width;
    if ( ! isset( $content_width ) ) $content_width = 640;
    register_nav_menus(
    array( ‘main-menu’ => __( ‘Main Menu’, ‘blankslate’ ) )
    );
    }
    add_action( ‘wp_enqueue_scripts’, ‘blankslate_load_scripts’ );
    function blankslate_load_scripts()
    {
    wp_enqueue_script( ‘jquery’ );
    }
    add_action( ‘comment_form_before’, ‘blankslate_enqueue_comment_reply_script’ );
    function blankslate_enqueue_comment_reply_script()
    {
    if ( get_option( ‘thread_comments’ ) ) { wp_enqueue_script( ‘comment-reply’ ); }
    }
    add_filter( ‘the_title’, ‘blankslate_title’ );
    function blankslate_title( $title ) {
    if ( $title == ” ) {
    return ‘→’;
    } else {
    return $title;
    }
    }
    add_filter( ‘wp_title’, ‘blankslate_filter_wp_title’ );
    function blankslate_filter_wp_title( $title )
    {
    return $title . esc_attr( get_bloginfo( ‘name’ ) );
    }
    add_action( ‘widgets_init’, ‘blankslate_widgets_init’ );
    function blankslate_widgets_init()
    {
    register_sidebar( array (
    ‘name’ => __( ‘Sidebar Widget Area’, ‘blankslate’ ),
    ‘id’ => ‘primary-widget-area’,
    ‘before_widget’ => ‘<li id=”%1$s” class=”widget-container %2$s”>’,
    ‘after_widget’ => “”,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’,
    ) );
    register_sidebar( array (
    ‘name’ => __( ‘Secondary Widget Area’, ‘blankslate’ ),
    ‘id’ => ‘secondary-widget-area’,
    ‘before_widget’ => ‘<li id=”%1$s” class=”widget-container %2$s”>’,
    ‘after_widget’ => “”,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’,
    ) );
    }
    function blankslate_custom_pings( $comment )
    {
    $GLOBALS[‘comment’] = $comment;
    ?>
    <li <?php comment_class(); ?> id=”li-comment-<?php comment_ID(); ?>”><?php echo comment_author_link(); ?><?php
    }
    add_filter( ‘get_comments_number’, ‘blankslate_comments_number’ );
    function blankslate_comments_number( $count )
    {
    if ( !is_admin() ) {
    global $id;
    $comments_by_type = &separate_comments( get_comments( ‘status=approve&post_id=’ . $id ) );
    return count( $comments_by_type[‘comment’] );
    } else {
    return $count;
    }
    }

    Thread Starter SU Mike

    (@su-mike)

    I created this test page, but i’m not sure how to share a .php page for viewing? Does this work? https://www.silveradotruckaccessories.com/testpage.htm

    Plugin Contributor Mike Jolley

    (@mikejolley)

    You could have added it to gist.github.com, but yes, if your paste is correct there is white space before the opening php tag.

    Thread Starter SU Mike

    (@su-mike)

    What’s this white space that you speak of?

    I’ve narrowed my issue down, when I edit the function.php code in my ‘Microsoft expression’ local web editor and upload it online it causes the error, but if I acces the function.php file direction through the admin panel and add the secondary-widget code and update it works just fine.

    I might have unknowingly run into this same issue in the past and worked my way around it so it is a relief to figure out, but I’m still curious as to what the ‘white space’ is as I haven’t touched anything in my beginning of my code and I need to know if my editors causing it.

    all I see is. . . .

    <?php
    add_action( ‘after_setup_theme’, ‘blankslate_setup’ );
    function blankslate_setup()

    which looks standard

    p.s. Thanks for your help thus far Mike! first time I’ve reached out for help and glad to know someone’s out there! ??

    Plugin Contributor Mike Jolley

    (@mikejolley)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Adding secondary-widget-area to 'blankslate' theme: Header sent out error’ is closed to new replies.