Child Style.css not overriding parent theme style located in assets/css/main.css

I know this question has been asked before, and I’ve already referenced the following questions here:

Child Theme Not Overriding Parent Theme

some things in child theme css not overriding parent

CSS in child theme not overriding the parent theme [closed]

Function in Child Theme not overriding Parent Theme function [duplicate]

None of these address my particular issue.

The issue I am having is that the stylesheet for my parent theme isn’t located in the traditional themedirectory/style.css. They did all the styling in themedirectory/assets/css/main.css. So I tried to create the child theme and added the following code to my functions.php file:

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'maya-reloaded-style';
        wp_enqueue_style( $parent_style, get_template_directory_uri() . 'assets/css/main.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' );
    ?>

I updated the directory of the parent theme to the location of the current parent theme, but I still have an issue of my new stylesheet not overwriting the parent’s child theme. It seems like the parent’s stylesheet is being loaded after the child style sheet. When I inspect the element with Firefox it shows that the parent stylesheet is overwriting the child stylesheet.

What am I doing wrong and how can I fix this so the child stylesheet is loaded after the parent stylesheet?

Read more here: Child Style.css not overriding parent theme style located in assets/css/main.css

Leave a Reply

Your email address will not be published. Required fields are marked *