0
votes

I am putting together a wordpress child theme based on a parent theme that has multiple style sheets in it's directory. So for example this is the navigation to a few of the style sheets:

  • parent-theme/style.css
  • parent-theme/css/style.css
  • parent-theme/css/bootstrap.css

I created my child folder and created my style.css file as well as my function.php file but it seems that the child theme is only pulling the style sheet for the parent-theme/style.css file and not pulling all the .css files.

After doing some digging this is where my functions.php file is at currently:

<?php

/* v1.0.5
Date: 5/15/17
*/


function my_theme_enqueue_styles() {

$parent_style = 'wizard-style'; // This is 'wizard' for the Wizard theme.

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

My main objective is to have the child theme pull all needed stylesheets and utilize the one single style sheet under my child them folder (child-theme/style.css) for any changes I would like to make.

My questions are:

  1. Is this possible?
    • If it is possible, what errors may be occurring that is causing my fucntion.php file not to pull all the stylesheets?
    • If it is not possible, what changes do I need to make to my function.php file and my directory to make this work?
2

2 Answers

1
votes

I had an issue like this with ArileWP theme, after a lot of research I figured out that loading multiple style sheets was not the issue (using the enqueue function on wordpress.org forums and other forums did in fact load all stylesheets regardless of whether they were in the root level or lower directory levels of the parent theme).

The issue in my case ended up being that Arile requires you to install their "arile extra" plugin, and this plugin has an if statement that is conditional on what your child theme is named:

if( 'ArileWP' == $activate_theme || 'Business Street' == $activate_theme || 'StrangerWP' == $activate_theme || 'NewYork City' == $activate_theme || 'InteriorPress' == $activate_theme || 'Arile WP Child' == $activate_theme ){
        require("inc/arilewp/arilewp.php");

Their plugin has a default name Arile WP Child that, if you are not using as the name of your child theme, the extra features included in the plugin will not execute.

The cleanest solution in my case was to simply change the name of my child theme to the one defaulted in their php file.

Might not be the same issue you are having but was a simple fix that just took me a long time to narrow down.

0
votes

Check the page 'view source' to make sure the style sheets are being loaded from the parent. When you activate a child theme its still pulling everything from the parent unless you override the specific file (example: header.php).

The functions.php and style.css files are the only exception as they supplement their corresponding parent theme file.

So, in summary those stylesheets should be included on your websites. Your theme settings may be incorrect but if you're in a pinch and just need to get those style sheets loaded just add them manually via the functions.php file by enqueuing them

EDIT: Does the child theme stylesheet contain the following commented out information customized for your theme, of course?

/*
Theme Name: Twenty Fifteen Child
Theme URI: URI
Description: Twenty Fifteen Child Theme
Author: John Doe
Template: twentyfifteen
Version: 1.0.0
Text Domain: twenty-fifteen-child
*/

If it isn't overriding the parent the styles it could possibly be a cache issue. If you don't have any cache plugins it could be your hosting environment or Cloudflare. If you can clear the server cache then refresh your browser with a Cntrl+F5 and see if that helps.

Did you try adding !important to your child styles for troubleshooting purposes already? Does your theme have a custom style option that lets to save styles to the database that it loads with each page to override the parent theme? Its not ideal but works if youre in a pinch.

Sorry if I am telling you elementary things I am not sure what your experience level is.