• Hello!

    It might have been covered before, I don’t know. Just can’t find the answer anywhere on the net nor in the forums here. But I might just have missed it…
    It’s getting me crazy, I’ve been on it for the whole day and can’t find the answer.

    Somehow the parent style.css keeps in control.
    I want to change the width parameter to 100% instead of 1000px.
    If I change it in the child style.css nothing happens. If I change it in the parent directly it does … but that’s just not the way it should be done …
    I want to understand.

    If I make other alterations in the child css it does work, so the css is recognized I would say.

    You can see my site: http://www.precies.net.
    I try to nudge the logo to the left of the screen.

    My function.php:
    ********************************************
    <?php
    function my_theme_enqueue_styles() {

    $parent_style = ‘twentyseventeen-style’; // This is ‘twentyfifteen-style’ for the Twenty Fifteen theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_style( ‘child-style’,
    get_stylesheet_directory_uri() . ‘/style.css’,
    array( $parent_style ),
    wp_get_theme()->get(‘Version’)
    );
    }
    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
    ?>
    ********************************************

    My child style.css:
    ********************************************
    /*
    Theme Name: precies
    Theme URI: http://www.precies.net/precies/
    Description: Twenty Seventeen Child Theme
    Author: TJR
    Author URI: http://example.com
    Template: twentyseventeen
    Version: 1.0.0
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
    Text Domain: precies
    */

    img{
    max-width: 100%;
    height: auto;
    }

    .site-content {
    background-image: url(“http://precies.net/typewriter-801917.jpg&#8221;);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    }

    .wrap {
    background-color: rgba( 250, 250, 250, 0.6)
    }

    /*.site-branding {
    display: none;*/
    }

    wrap {
    max-width: 100%;
    padding-left: 3em;
    padding-right: 3em;
    }

    ********************************************
    The part in the parent style.css that overrules:
    at line 3326
    ********************************************
    /* Layout */

    .wrap {
    max-width: 1000px;
    padding-left: 3em;
    padding-right: 3em;
    }

    ********************************************

    any help or explanation would be greatly appreciated!

    Cheers,
    Taco

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there,

    The solution to your problem looks pretty simple.

    wp_enqueue_style(‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array( $parent_style ), wp_get_theme()->get(‘Version’));

    Should Be

    wp_enqueue_style(‘precies’, get_stylesheet_directory_uri() . ‘/style.css’, array( $parent_style ), wp_get_theme()->get(‘Version’));

    I can see you’ve used the WordPress documentation to copy that function to add a child CSS file to your child theme, but you didn’t actually put your theme name into the wp_enqueue_style.

    Fairly simple mistake to make, to help in the future I’d suggest reading up on http://www.php-fig.org/psr/ to get an idea of PHP coding / styling standards as the way some of your code is formatted (maybe the WYSIWYG just didn’t carry over formatting) makes it unnecessarily hard to read.

    Thread Starter tjr1969

    (@tjr1969)

    Thanks for your reply giollianosulit,

    I agree with you that your solution would apear to be it.
    Neverthelesss I did try with numerous variations and it still doesn’t resolve my problem. (precies, precies-style, precies_style, ‘precies’, ‘precies-style, ‘precies_style’)

    Strange enough it seems that the style sheets are connected once i watch the source-code of the page:

    <link rel='stylesheet' id='dashicons-css'  href='http://www.precies.net/wp-includes/css/dashicons.min.css?ver=4.8' type='text/css' media='all' />
    <link rel='stylesheet' id='admin-bar-css'  href='http://www.precies.net/wp-includes/css/admin-bar.min.css?ver=4.8' type='text/css' media='all' />
    <link rel='stylesheet' id='twentyseventeen-style-css'  href='http://www.precies.net/wp-content/themes/twentyseventeen/style.css?ver=4.8' type='text/css' media='all' />
    <link rel='stylesheet' id='precies-css'  href='http://www.precies.net/wp-content/themes/precies/style.css?ver=1.0.0' type='text/css' media='all' />
    <link rel='stylesheet' id='twentyseventeen-fonts-css'  href='https://fonts.googleapis.com/css?family=Libre+Franklin%3A300%2C300i%2C400%2C400i%2C600%2C600i%2C800%2C800i&subset=latin%2Clatin-ext' type='text/css' media='all' />

    I expect that I could make it work the old fashioned one using import, but I just would like to make it work how it should be …

    Thanks for any further ideas.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Child theme not getting priority over parent style.css’ is closed to new replies.