• Resolved elinbruun

    (@elinbruun)


    Hi

    Tried making a cild theme but now I ge the following errormessage:

    Warning: Cannot modify header information – headers already sent by (output started at /var/www/svenskdansk.nu/public_html/wp-content/themes/twentyseventeen-child/functions.php:1) in /var/www/svenskdansk.nu/public_html/wp-admin/includes/misc.php on line 1126

    Here is my code:
    style.css:

    /*
    Theme Name: Twenty Seventeen Child
    Theme URI: https://svenskdansk.nu
    Description: Twenty Seventeen Child Theme
    Author: Elin Bruun
    Author URI: https://svenskdansk.nu
    Template: twentyseventeen
    Version: 1.0.0
    License: GNU General Public License v2 or later
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
    Text Domain: twenty-seventeen-child
    */

    styles.php

    <?php
    add_action( ‘wp_enqueue_scripts’, ‘load_parent_styles_when_child_active’ );
    function load_parent_styles_when_child_active() {
    if ( is_child_theme() ) {
    wp_enqueue_style( ‘parent-style’, trailingslashit( get_template_directory_uri() ) . ‘style.css’ );
    }

    }

    What shoul i do?

    best regars Elin

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can I double check that you created a ‘styles.php’ file inside your Child Theme folder? That’s not the right file. The file you should have created is ‘functions.php’.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Once you’ve got that functions.php file created, add this bit of code to the bottom of that file:

    
    ?>
    
    Thread Starter elinbruun

    (@elinbruun)

    Hi Andrew

    Thank you so much for replying. I just mixed things up, when writing this entry, and the file was/is of course called functions.php

    I now added the ?>

    However the error message persists

    Thread Starter elinbruun

    (@elinbruun)

    Hi again

    Actually the message is a new one:

    Warning: Cannot modify header information – headers already sent by (output started at /var/www/svenskdansk.nu/public_html/wp-content/themes/twentyseventeen-child/functions.php:10) in /var/www/svenskdansk.nu/public_html/wp-includes/pluggable.php on line 1219

    //Elin

    Thread Starter elinbruun

    (@elinbruun)

    changed the script to this:

    <?php
    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
    function my_theme_enqueue_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );

    }
    ?>

    Now my site is not down anymore, at least:)

    I recently had similar issues and found it was a simple/ridiculous fix of making sure there are no spaces or blank lines after the final ?> in functions.php

    I had same case as @caseywp that I got errors and after I removed blank line after final ?> in child theme’s functions.php everything is fine.

    Error in browser:

    
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/themes/mytheme-child/functions.php:16) in /var/www/html/wp-login.php on line 447
    
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/themes/mytheme-child/functions.php:16) in /var/www/html/wp-login.php on line 462
    
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Warning when creating child theme’ is closed to new replies.