0

before I begin I apologize if I have terrible English as it is not my primary language.

I am trying to create a child theme for a website I am working on. The website uses Comicpress theme. I have already created the child and it seems to be working correctly. However I have encountered two issues:

1.) The grey boarder around my post seems to be missing. I am unsure as to why.

2.) I am unable to edit the child's CSS in order to override the parent's.

Can someone please help me out? I will provide the codes I have used and screen shots for comparison. Thank you very much.


PARENT THEME enter image description here CHILD THEME enter image description here

CHILD'S STYLE.CSS

CHILD STYLE.CSS

/*
Theme Name: ComicPress-Child
Version: 1.0
Description: A child theme of ComicPress
Template: comicpress
*/

CHILD FUNCTION.PHP

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

    wp_enqueue_style( 'child-style'
        , get_stylesheet_directory_uri() . '/child-style.css'
        , array('parent-style') // declare the dependency
                                // in order to load child-style after parent-style
    );
}
0

1 Answer 1

2

good question! Basically, in your enqueue you call the Parent stylesheet first then the child, so any child styles (by definition of css specificity) will override the parent styles.

Code example from the WordPress codex: https://codex.wordpress.org/Child_Themes

<?php
function my_theme_enqueue_styles() {
    $parent_style = 'parent-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' );
?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.