In the last month I have been creating my very first website. Before this I had no coding knowledge so everyhting I learnt was new to me.
My problem over the last week is that my child theme .css files (and php. file but that is a different matter) are not overriding their parent .css files. I have been trying to search for a solution all week but have had no success so far.
This is the code I put into the child functions.php file
=============================================================== (5) - This code allows the child-theme to be read last, but some other css (that must rely on something else?) causes some errors/
<?php
function my_theme_enqueue_styles() {
$parent_style = 'adforest-original-modern'; // This is 'adforest-style' for the AdForest theme.
wp_enqueue_style( $parent_style, get_template_directory_uri().'/css/modern.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri().'/modern.css',
array( $parent_style ),
wp_get_theme()->get('1.0.0'));
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function wp_67472455() {
wp_dequeue_style( 'adforest-theme-modern' );
wp_deregister_style( 'adforest-theme-modern' );
}
add_action( 'wp_print_styles', 'wp_67472455', 100 );
?>
==========================================================
(6) - THIS FOLLOWING CODE WORKS, CAN ANYONE SEE POTENTIAL ISSUES WITH THIS CODE?
<?php
function my_theme_enqueue_styles() {
/* =================== modern.css ==========================*/
$parent_style = 'adforest-original-modern'; // This is 'adforest-style' for the AdForest theme.
wp_enqueue_style( $parent_style, get_template_directory_uri().'/css/modern.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri().'/modern.css',
array( $parent_style ),
wp_get_theme()->get('1.0.0'));
/* =================== default.css ==========================*/
wp_enqueue_style( 'defualt-original-color', get_template_directory_uri().'/css/colors/defualt.css' );
wp_enqueue_style( 'child-defualt-color',
get_stylesheet_directory_uri().'/defualt.css',
array( 'defualt-original-color' ),
wp_get_theme()->get('1.0.0'));
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', 100 );
function wp_67472455() {
/* =================== modern.css ==========================*/
wp_dequeue_style( 'adforest-theme-modern' );
wp_deregister_style( 'adforest-theme-modern' );
/* =================== default.css ==========================*/
wp_dequeue_style( 'defualt-color' );
wp_deregister_style( 'defualt-color' );
}
add_action( 'wp_print_styles', 'wp_67472455', 1 );
?>