• Resolved Arial73

    (@arial73)


    Hi there,
    I’m running WP 4.0.1, twentyeleven v 19., and I have written a child theme as per the codex.
    My child theme, when I attempt to activate it, seems to revert to an unmodified twentyeleven look; none of my customizations carry through.

    Here’s my stylesheet

    /*
     Theme Name:   Twenty Eleven Child
     Theme URI:    http://www.pvccart.com/here/wp-content/themes/twentyeleven-child
     Description:  Twenty Eleven Child Theme
     Template:     twentyeleven
     Version:      1.0.0
     Tags:         light, dark, single-column, responsive-layout, accessibility-ready
     Text Domain:  twenty-eleven-child
    */
    
    /* =Theme customization starts here
    -------------------------------------------------------------- */

    And here is my functions.php

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'../twentyeleven/style.css' );
    }

    Finally, here’s a screenshot of the parent theme…

    ..and after child theme activation..

    Thank you in advance for any help or ideas.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Moderator t-p

    (@t-p)

    try enquing style sheets as follows and see if it helps (in your child theme’s functions.php):

    add_action( 'wp_enqueue_scripts', 'load_my_parent_styles' );
    function load_my_parent_styles() {
        wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '/style.css' );
    }
    
    add_action( 'wp_enqueue_scripts', 'load_my_child_styles', 20 );
    function load_my_child_styles() {
        wp_enqueue_style( 'child-theme', get_stylesheet_uri() );
    }
    Thread Starter Arial73

    (@arial73)

    Sorry, that change had no effect. I tried it once with your exact code, and one with this line

    wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '/style.css' );

    changed to this

    wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '../twentyeleven/style.css' );
    Moderator t-p

    (@t-p)

    try removing the enquing of parent-theme css, see if that helps

    Thread Starter Arial73

    (@arial73)

    Can you provide a code example please?

    none of my customizations carry through.

    a child theme is treated like a new theme for which you will need to re-do the customization like header, background, menu, etc.

    Thread Starter Arial73

    (@arial73)

    AH…
    See, the point that Alchymyth just made is new to me. I suggest that the codex be modified to include this point; namely that a child theme does not inherit theme customization.

    Thread Starter Arial73

    (@arial73)

    WAIT
    Belay that; this topic is not resolved.

    Look carefully at my images. You will see that my child theme is not even importing the default look of the twenty eleven theme.

    Is my child theme not pulling some theme-specific files for twentyeleven?

    To pull styles from your parent theme to your child theme, use this line as the first non-comment line in your child theme’s style.css.

    @import url("../twentyeleven/style.css");

    After that, put any child theme specific style changes.

    Moderator t-p

    (@t-p)

    Please see this Codex article, which does not recommend the use @import anymore…

    http://codex.wordpress.org/Child_Themes

    Hello !
    Please, I am facing the same trouble.
    Have we to replace the words ‘parent’ by our ‘parent-theme-name’ in the code portion which is on the Codex and that Tara shared a few days ago ?

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'../twentyeleven/style.css' );
    }

    if yes, where exactly ?

    thanks in advance

    Moderator t-p

    (@t-p)

    @titacrea:
    To get full attention to your specific issue, my suggestion would be to start your own thread. Despite any similarity in symptoms, your issue is likely to be completely different because of possible differences in physical servers, accounts, hosts, plugins, theme, configurations, etc. Thus one problem, on one setup is not indicative of the functionality and reliability of an application as a whole. To get the best attention to your specific issue as you deserve, please review how and where to post in this forum: http://codex.wordpress.org/Forum_Welcome#Where_To_Post

    Thread Starter Arial73

    (@arial73)

    Hello again,
    I have one other thought which is that my database may be overriding my child theme. I did a little digging and found that the tables corresponding to my current theme are significantly different than the table for my child theme. If they are of use to anyone, I can post them here, but for now it’s enough to say that my controls within theme customization of wp-admin seem to be overridden by something in my database.
    A final complication is that this 2011 theme was modified by my predecessor and I have not been able to identify where he made the visual alterations to the stock theme, which in turn makes me suspect that he altered something which is now affecting my child theme.

    You can probably tell that I’m not a WP theme developer, and so I would appreciate any breadcrumbs or clarifying questions regarding this issue.
    Thank you again.

    I don’t think the database is overriding the child theme. There isn’t one table per theme, all theme options are in the wp_options table. The option_name field defines which option belongs to which theme, thus keeping each theme separate.

    If the parent theme has been modified by your predecessor, presumably he did not make a child theme? So what he may have done is to modify the theme style sheet and possibly the theme functions.php. This is not the recommended way, since you cannot now update your TwentyEleven from version 1.4 to the current 1.9, because the customisations will be overwritten. Not being able to parent update your theme locks you into old software which may eventually break. Version 1.4 may not fully cooperate with much later versions of WordPress and plugins.

    As noted above, all options, settings and widgets need to be copied manually from the parent theme to the child, because they are different themes.

    Have you checked the markup for the child theme to make sure twentyeleven/style.css is in fact being included?

    You could also put your child theme url through this service:
    http://jigsaw.w3.org/css-validator/
    Some css errors don’t have serious effect but some parse errors can halt interpretation of the style sheet to the extent that chunks of it may not be being read.

    Has this issue had a successful response? I am having the very same issue where my parent’s styling is not being inherited when the child is activated. I have tried the code suggested above to no avail. I have tried the import statement in the style.css file and that method doesnt help either. What else could possibly be going on?

    alchymyth: You say:
    “a child theme is treated like a new theme for which you will need to re-do the customization like header, background, menu, etc.”
    This does not make sense. The child theme is loaded after the parent theme, so all the parent theme changes should take place and then any changes you want the child theme to do. That is what all the documentation says. That import statement in the style sheet or the enqueue statement in the php file, which ever method one uses, should load the parent stylesheet and then impose any changes to the style that the child stylesheet has. In my case, all I want to do is to load the parent stylesheet correctly and then start making some small changes. But I am getting a blank style with all the colors and background images gone.

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Trouble with child theme (it's not inheriting my parent styles)’ is closed to new replies.