• Resolved Henriette Stewart

    (@mountainshade1)


    I have a multisite ‘website.com’ which has child site ‘childsite’ in a sub-folder set up, so the link to child site is website.com/childsite. All working perfectly on my custom ‘websitetheme’. Now I am trying to create a child theme for childsite ‘websitetheme-childtheme’ but I simply cannot get this to work.

    What is happening is that the childsite’s name is inserted into some the links, like this: website.com/childsite/wp-content/themes/websitetheme-childtheme/library/css/style.css as if ‘childsite’ was a directory, which it obviously is not.

    My .htaccess file:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    My child-theme stylesheet:

    /*
     Theme Name:   Website theme
     Theme URI:    https://website.com/
     Description:  Childsite theme for Website theme
     Author:       Henriette
     Author URI:   https://www.henriettemadeup.com
     Template:     websitetheme
     Version:      1.0.0
    */
    @import url("../websitetheme/style.css");
    
    /* =Theme customization starts here
    -------------------------------------------------------------- */

    I am completely puzzled about this problem and desperately hope someone is able to help me figure this one out. Many thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    What is happening is that the childsite’s name is inserted into some the links, like this: website.com/childsite/wp-content/themes/websitetheme-childtheme/library/css/style.css as if ‘childsite’ was a directory, which it obviously is not.

    This is not wrong.

    website.com/childsite/ works, right? I mean it displays content. That’s because the ‘childsite’ folder is virtual ??

    That’s what this htaccess rule does:

    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

    So it’s not working. Does this happen on ALL themes or just this one?

    Thread Starter Henriette Stewart

    (@mountainshade1)

    This is not wrong.

    website.com/childsite/ works, right? I mean it displays content. That’s because the ‘childsite’ folder is virtual ??

    Ah, I see. I get that the childsite is virtual, which is why I was thinking that this is what breaks the links, but I have to admit I do not understand RegEx enough to know which rule does what.

    Does this happen on ALL themes or just this one?

    So far I have only made one child theme which I want to get working before making more. The main theme, which is built on top of Eddie Machado’s Bones theme, works perfectly on both the main site and all the child sites.

    I have just done a little experiment and the child theme’s stylesheet will sort of work if I create the /library/css/ structure inside the child theme. (I say ‘sort of’ because the styles will only show up if I set everything to !Important :P)

    Could it be the ‘websitetheme-childtheme’ (the child theme’s name) part of the links that messes this up, or should .htaccess take care of that too? For instance, I don’t have a js file in the child theme, but one of the broken links is structured like this: website.com/childsite/wp-content/themes/websitetheme-childtheme/library/js/scripts.js

    I’m starting to wonder if it’s the base theme (Bones) I’m using as a base for websitetheme that is to blame. I think my next step will be to switch to twentyfourteen and make a child theme there, and see if that works. Will report back on how that works out.
    Thanks for your help so far Mika. ??

    Thread Starter Henriette Stewart

    (@mountainshade1)

    OK, so switching to twentyfourteen and making a child theme works perfectly. This must mean that it’s the base theme I’ve developed on which is to blame. Hugely annoying as I’ve spent time styling and branding this theme for my client, but oh well. Square one, we meet again.
    If I do manage to find the issues and use my original custom theme, I’ll post my solution here.
    Not sure if I should mark this as resolved because though I think I’ve found the area where the fault is, I still have no solution, other than using a different base theme. I’ll let the good mods here decide. ??

    Thread Starter Henriette Stewart

    (@mountainshade1)

    Problem solved! Here’s how:

    It was the Bones development theme that was causing it.
    Within the theme there is a file called bones.php where wp_register_script & wp_register_styles enqueues styles and scripts, but it does it using the get_stylesheet_directory_uri function where it should have been get_template_directory_uri. I happily stumbled upon this post by John Bhartley where he describes how he solved this problem.
    I also found a multisite project built on the Bones development theme, with child themes, on github where I could check their set-up.

    What I did was I swapped all the get_stylesheet_directory_uri for get_template_directory_uri in bones.php and created a /library/css/ directory wihtin the child theme where I put a copy of the child theme’s styles.css, leaving the original in the child theme’s root.
    Bones doesn’t actually register its root style.css file (as far as I can tell) but WordPress still seems to look for it when you use child themes, which is why (I think) you need styles.css both in the root of the child theme and inside a /library/css/ directory.
    In any case, that’s what fixed it for me.

    Will now mark this topic as resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multisite (subfolder set-up) child theme not linking properly’ is closed to new replies.