0
votes

I'm very confused and need your help! I created Twenty Sixteen child theme and everything was working perfect, the child style was overriding the parent's one. Then suddenly, when I made a little change of the menu in the WP admin, child css stopped being dominant. After this in all child theme I've created, parent style always overrides child css. Here is the code I put into child css.

/*  Theme Name:   Proservice_2016
    Description:  Proservice Theme
    Author:       VB
    Template:     twentysixteen
    Version:      1.0.0
    Tags:         light, dark, two-columns, right-sidebar, responsive-  layout, accessibility-ready
    Text Domain:  proservice
 */

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

Also in functions.php I inserted the following code

<?php
 function parent_css_theme_style() {
 wp_enqueue_style( 'parent-style',   get_stylesheet_directory_uri().'/style.css' );
 }
add_action( 'wp_enqueue_scripts', 'parent_css_theme_style' );
add_action( 'wp_enqueue_scripts');
?>
1
get_stylesheet_directory_uri() does not return a URI for a parent theme...It returns the directory URI for the current/child theme.rnevius
In your functions.php file change get_stylesheet_directory_uri() with get_template_directory_uri() codex.wordpress.org/Child_ThemesJavier Gonzalez
I've changed to get_template_directory_uri() but this way it doesn't work as well. The parent css works perfecty for child theme but it overrides child css and none of my changeas are visibleAurélie Lepage
Delete the line: @import url("../twentysixteen/style.css"); in your child theme style.css its not necessary, all the information you need is on the page I send you. Hope it helpsJavier Gonzalez

1 Answers

0
votes

Here a working example as I tried it:
functions.php

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

All the information you need: https://codex.wordpress.org/Child_Themes