• Resolved jgstroup

    (@jgstroup)


    I may have to give up on this theme.

    First I’ve discovered that the “featured image” capability works differently with this theme than any other I’ve tried.

    Now I’m finding that when creating a child-theme that simple font changes in style.css are ignored.

    None of this is documented anywhere I can find.

    Its too bad, because the general layout of twenty-eleven works well for my project – and the “Layout” feature on the “customization” screen may come in handy. I haven’t yet spotted that feature on the other free themes I’ve examined.

    Anyway – if there’s some trick to making child themes for twenty-eleven that will allow changes to font styles – and maybe other CSS settings, I’d appreciate some guidance. Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Which font styles are you trying to change? It may be that you aren’t using specific enough CSS to override the default styling set in the parent style.css

    I’ve been looking through the code, and I can’t even see where the style.css is loaded.
    The child theme definitely needs to load its own style sheet.
    If you were wanting to change the font family, you will be needing to load the font file in your child theme. Other font properties are easier.

    being quite an old theme, Twenty Eleven loads the stylesheet in header.php with this line:

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    

    this actually loads the stylesheet of the activated theme (the child theme).

    when you use the typically suggested code in functions.php of a child theme:

    //enqueue parent theme style.css//
    add_action( 'wp_enqueue_scripts', 'twentyelevenchild_enqueue_styles' );
    function twentyelevenchild_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }

    this unfortunately loads the parent style.css later after the child theme style.css, making overwriting CSS using identical selectors virtually impossible.

    two ways around it:

    – either editing header.php in the child theme, and changing this line to:
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>" /> to load the parent theme style.css,
    and changing the enqueuing code in functions.php of the child theme to:

    //enqueue child theme style.css//
    add_action( 'wp_enqueue_scripts', 'twentyelevenchild_enqueue_styles' );
    function twentyelevenchild_enqueue_styles() {
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css' );
    }

    – or editing the enqueuing code in functions.php of the child theme to load the child theme style.css after the parent theme style.css:

    //enqueue parent and child theme style.css//
    add_action( 'wp_enqueue_scripts', 'twentyelevenchild_enqueue_styles' );
    function twentyelevenchild_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css' );
    }

    this unfortunately loads the child theme style.css twice (once from the code in header.php and the second time from the enqueuing), but should solve the problem with oversriting styles.

    Thread Starter jgstroup

    (@jgstroup)

    Bingo!

    Thanks Michael!

    I’ve been using a tutorial that didn’t anticipate this.

    I’ll work on it tomorrow when I’m fresh using your guidance.

    Hey, I didn’t realize this theme had a hard-coded link, which is against the theme review requirements. I think Kjell might fix it (change it to enqueue the style sheet).

    Thread Starter jgstroup

    (@jgstroup)

    Some times it takes a fresh set of eyes to find things.

    The question for me is if this sort of thing is an outlier or commonplace.

    I appreciate everyone’s help and support as I keep looking…

    Apparently, there was a ticket and a patch 7 years ago for this, but it was reverted since it affected child themes that were already written. But the patch didn’t check for whether it was in a child theme… But that wouldn’t really help new child themes either.
    With thousands of themes in the WP repository, and more outside it, there is no good way for one person to tell you “if this sort of thing is an outlier or commonplace”.
    We do have requirements that themes must meet before they can be in the repository, but the requirements change over the years and the themes may or may not get updated.

    Thread Starter jgstroup

    (@jgstroup)

    Makes perfect sense to me.

    Looking at the theme home pages on www.ads-software.com I see the ability to input “add my review” – and “report this theme”.

    The most recent review for twenty-eleven is over 3 and a half years ago. The lowest rating is 3-stars – only one that low – and it’s over 4 years ago.

    There’s no way to view the catalog of “report this theme” entries – and the submission form says no answers will be provided – questions should be directed to the forums.

    I’ll do my part and enter both a review, and report the problems I’ve observed.

    I would suggest that the tutorials and textbooks for new WordPress users advise new WordPress users look though the available documentation and reviews – but it doesn’t seem to be common practice for others to raise red flags – so little benefit to that.

    Perhaps the best advice is that extensive theme functionality testing be done with minimal content before making a significant time investment in building content.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Child style.css ignored’ is closed to new replies.