1

A few years back, I made some css and template changes directly in my parent theme, because Wordpress was new to me and that seemed easier than messing around with this child theme stuff. It worked fine and I only had to redo it once when the theme updated. Fortunately I had kept records of my changes. Now I have more changes to do and decided to learn how to do it the right way. So far I can't even get my child theme working the same as things have been, though. My child alterations to the main style.css seem to be working fine, however there are several other parent theme css files in a /css folder, and the child theme seems to be ignoring them no matter what I do.

Here's the relevant portion of the parent functions.php:

function custom_admin_enqueue() {
    wp_enqueue_script('admincustom', get_template_directory_uri() . '/js/admincustom.js');
    wp_register_style('seometa_wp_admin_css', get_template_directory_uri() . '/css/seometa.css');
    wp_enqueue_style('seometa_wp_admin_css');
}
add_action('admin_enqueue_scripts', 'custom_admin_enqueue');
function lbt_theme_styles() {
    wp_register_style('stylehover', get_template_directory_uri() . '/css/style.css');
    wp_register_style('fontawesome', get_template_directory_uri() . '/css/font-awesome.css');
    wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css');
    wp_register_style('styleisotop', get_template_directory_uri() . '/css/styleisotop.css');
    wp_register_style('slicknav', get_template_directory_uri() . '/css/slicknav.css');
    wp_register_style('styleslide', get_template_directory_uri() . '/css/style-slide.css');
    wp_register_style('jqueryfancybox', get_template_directory_uri() . '/css/jquery.fancybox.css');
    wp_register_style('300', get_template_directory_uri() . '/css/300.css');
    wp_register_style('440', get_template_directory_uri() . '/css/440.css');
    wp_register_style('740', get_template_directory_uri() . '/css/740.css');
    wp_register_style('960', get_template_directory_uri() . '/css/960.css');
    wp_register_style('nivoslider', get_template_directory_uri() . '/css/nivo-slider.css');
    // Styles
    wp_enqueue_style('stylehover');
    wp_enqueue_style('fontawesome');
    wp_enqueue_style('flexslider');
    wp_enqueue_style('styleisotop');
    wp_enqueue_style('slicknav');
    wp_enqueue_style('styleslide');
    wp_enqueue_style('jqueryfancybox');
    wp_enqueue_style('300');
    wp_enqueue_style('440');
    wp_enqueue_style('740');
    wp_enqueue_style('960');
    wp_enqueue_style('nivoslider');
}

The key files here are the 300, 440, 740, and 960. Those are the ones I can tell immediately aren't being loaded (they control how the layout shifts for narrower screens), and also except for 960 the only ones I need to make changes/additions to.

After many iterations of things that didn't work, I've arrived at this code, which also doesn't work, but continued searching though tutorials and old help forum posts aren't getting me any further than this:

  add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles',999 );
  function theme_enqueue_styles() {
     wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
     wp_enqueue_style( 'stylehover', get_template_directory_uri() . '/css/style.css' );
     wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/css/font-awesome.css' );
     wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );
     wp_enqueue_style( 'styleisotop', get_template_directory_uri() . '/css/styleisotop.css' );
     wp_enqueue_style( 'slicknav', get_template_directory_uri() . '/css/slicknav.css' );
     wp_enqueue_style( 'styleslide', get_template_directory_uri() . '/css/style-slide.css' );
     wp_enqueue_style( 'jqueryfancybox', get_template_directory_uri() . '/css/jquery.fancybox.css' );
     wp_enqueue_style( '300', get_template_directory_uri() . '/css/300.css' );
     wp_enqueue_style( '440', get_template_directory_uri() . '/css/440.css' );
     wp_enqueue_style( '740', get_template_directory_uri() . '/css/740.css' );
     wp_enqueue_style( '960', get_template_directory_uri() . '/css/960.css' );
     wp_enqueue_style( 'nivoslider', get_template_directory_uri() . '/css/nivo-slider.css' );
     wp_enqueue_style( 'seometa_wp_admin_css', get_template_directory_uri() . '/css/seometa.css' );
     
     wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
     wp_enqueue_style( '300', get_stylesheet_directory_uri() . '/300.css', array( '300' ) );
     wp_enqueue_style( '440', get_stylesheet_directory_uri() . '/440.css', array( '440' ) );
     wp_enqueue_style( '740', get_stylesheet_directory_uri() . '/740.css', array( '740' ) );
}

What's the trick that I'm missing? Thank you!

2
  • I'm pretty sure you can't reuse the same handles for different files. I'm not in a position to test this. Try using the naming convention 'parent-300' and 'child-300' for your handles. Make sure you update the handle names used in the dependencies arrays also – Paul G. May 12 at 22:06
  • Paul: I actually had it like that on a prior attempt and it wasn't working then either. Somebody elsewhere had me dump it all for this code and it seems to be ok, or at least now it's reading the stylesheets from the parent's /css folder: add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array(), '1.0' ); } – Ray Kremer May 12 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.