1

I am using the Optimizer theme and created a child theme to make 2 changes in the style.css. The .single_wrap adjustment works fine, but the page_head is being ignored. When I use Inspect Element on Google Chrome I can tell the parent style.css overides the child style.css for this part. Page_head is the title banner on my pages. Anyone know what's up?

style.css

/*
 Theme Name:   optimizer_child
 Template:     optimizer
*/

/* =Theme customization starts here
-------------------------------------------------------------- */
.single_wrap {
  margin-left: auto;
  margin-right: auto;
  float: none;
}

.page_head {
  min-height: 100px;
}

functions.php

<?php

add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

Website: http://www.gelnagels-gina.be

1

1 Answer 1

1

Style is not from parent CSS it is from themes/optimizer/style_core.css Then you can enqueue your child CSS on highest priority.

enqueue the parent style then child style on high priority

function enqueue_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_child_theme_style() {
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_style', 100 );
7
  • Damn, I just noticed that too :P What do you mean by enqueuing for highest priority? SHouldn't I just create a style_core.css in my child theme?
    – CustomX
    Commented Apr 19, 2015 at 19:02
  • You are using hook to enqueue your child css or it is hardcoded in you header. If you are using add_action hook then increase the priority to something 100 or more OR if you just placed it to header then place it just below the wp_head
    – Sumit
    Commented Apr 19, 2015 at 19:08
  • I am using the add action, but I'm not quite sure what you mean by setting the priority. In the code sample I added above, that's all I've got in my functions.php.
    – CustomX
    Commented Apr 19, 2015 at 19:14
  • like this add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style', 100 ); It will change the position of your style in head I mean below to other css if you require more and increase the number.
    – Sumit
    Commented Apr 19, 2015 at 19:18
  • Do it for your child css not for the parent.
    – Sumit
    Commented Apr 19, 2015 at 19:19

Your Answer

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

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