Child theme function.php widget problem
-
I am using a child theme with customizr. I am using the enqueue method in function.php. There does not seem to be anything wrong with my child themes style.css file. It cheks out with no errors in a Lint validator. If i switch back to the customizr theme and put the childs themes style.css contents in the advanced css box everything works fine. When i go back to my child theme, all the style changes are fine but the widgets are in the wrong place. The left side bar widget goes to the top and the right side widget goes to the bottom. I have even tried two different function.php files that i found and bot behvae the same.
<?php
function themeslug_enqueue_style() {
if ( is_child_theme() ) {
// load parent stylesheet first if this is a child theme
wp_enqueue_style( ‘parent-stylesheet’, trailingslashit( get_template_directory_uri() ) . ‘style.css’, false );
}
// load active theme stylesheet in both cases
wp_enqueue_style( ‘theme-stylesheet’, get_stylesheet_uri(), false );
}add_action( ‘wp_enqueue_scripts’, ‘themeslug_enqueue_style’ );
?>and another one
<?php
remove_action(‘wp_print_styles’, ‘cc_tabby_css’, 30);function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );}
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );?>
I am amazed at how different they both are but they both execute the style changes properly but both move the widgets. Can anybody help.
ThanksThe page I need help with: [log in to see the link]
-
Hi John,
in CSS the rules loading order makes a lot of difference.
When there are two (or more) rules with same specificity, the latter will override the previous one.Anyway the Customizr theme doesn’t need any additional code in the child-theme functions.php, to load the child-theme stylesheet:
The Customizr theme takes care about loading it ensuring the correct order (after the parent theme stylesheet).About your issue with the sidebar:
I can see from your page that the div withid="content"misses theclassattribute value – which is needed to give a certain width to it.
https://github.com/presscustomizr/customizr/blob/v4.0.16/index.php#L24So there’s something in your child-theme php part (did you override any php file?) that causes that.
Thank you so much Rocco. With your help in tracking it down it is now solved. I checked all my .php files in the child theme and it was my childs index.php causing the problem and I do not even know why it was there as I am sure it is not needed. I had copied the customizer theme index.php across to the child theme. Maybe by accident with a double click on a directory in Filezilla. With it deleted it all works fine. I think unless you have made changes you do not actually need the.php files at all for a child theme apart from function.php to do the enqueing. Is that right?
Hi john,
glad you solved.Yes that’s right, even the child-theme functions.php is not strictly needed to make a child-theme, but unless your aim is to change only the CSS, you might need it in the future.
Best regards.
Rocco
The topic ‘Child theme function.php widget problem’ is closed to new replies.
