WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Broken child-theme (25 posts)

  1. Programul ESL
    Member
    Posted 9 months ago #

    Hi,
    I have made some changes to my parent theme, which is Twenty eleven, before I found out that I should have created a child-theme and alter that instead of the parent theme.
    So I decided to create a child theme, I followed all the steps, created a "twenyeleven-child" folder inside the themes folder, put a style.css in it and copied the following code in the .css file:

    [ Moderator note: please wrap code in backticks or use the code button. Do not use single quote. ]

    /*
     Theme Name:     Twenty eleven Child
     Theme URI:      http://example.com/twenty-thirteen-child/
     Description:    Twenty eleven Child Theme
     Author:         John Doe
     Author URI:     http://example.com
     Template:       twentyeleven
     Version:        1.0.0
    */
    
    /* =Imports styles from the parent theme
    -------------------------------------------------------------- */
    @import url('../twentyeleven/style.css');
    
    /* =Theme customization starts here
    -------------------------------------------------------------- */

    But when I go to the Dashboard and try to activate it, it says "Broken Theme bla bla bla Template missing". I checked the spelling of the template, it matches exactly the name of the parent-theme folder, "twentyeleven" that is, no caps, no spaces. The name of the style.css file is exactly like that, no caps no nothing.

    I read on the forum something about a "nested folders" problem, but the topic was closed before further explanations. So I need to add that my wordpress site is not installed directly in the "www" folder from the server,where my other HTML based site is, as I am still working on the wordpress site and don't want to make it public yet.
    Instead, I created a folder named "wordpress", inside the "www" folder, and I have installed there the whole wordpress, with themes and all. Could that be a problem?

    Thank you for your help.

  2. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    Is the parent theme installed? Is the file structure correct:

    wp-content
         themes
             twentyeleven
             twentyelevenchild
                style.css
  3. Programul ESL
    Member
    Posted 9 months ago #

    Yes, the parent theme is installed and working properly. Yes, the file structure is correct as you described it.

  4. leejosepho
    Member
    Posted 9 months ago #

    I have made some changes to my parent theme, which is Twenty eleven

    Have you corrected that by installing a fresh, original copy?

  5. Programul ESL
    Member
    Posted 9 months ago #

    I just did that. Installed a fresh original Twenty eleven theme, up to date. My child theme is still broken and off course, all may customisation is gone (i have saved the customised CSS in another file off course, it is not completly gone, just gone from the site).
    What can I do next?
    My site is http://www.programul-esl.ro/wordpress if that helps in any way.

  6. leejosepho
    Member
    Posted 9 months ago #

    no caps, no spaces

    Try something very simple like 20my11 as a name for your Child Theme and its folder to see whether that might help. Also, double check your style.css to get rid of any spaces at the ends of lines and no empty lines anywhere. And if you are not already using something as format-free as Text Pad (or Notepad in plain text), get a trustworthy file editor like Notepad++ if you do not already have one.

    (i have saved the customised CSS in another file off course, it is not completly gone, just gone from the site)

    Good move!

  7. Programul ESL
    Member
    Posted 9 months ago #

    I changed the name of the child-theme folder to 20my11. I have rechecked the code (allthough I have copy-pasted it from wordpress codex...), eliminated all the spaces from the end of the lines, no empty lines. No luck.
    The curious thing for me is that it's saying "template missing", as if it cannot find the parent-theme folder. But the folder is there, the parent theme is installed and working, and I've double checked to make sure that the name of the parent-theme folder and the name of the template from the child-theme's .css match. I even copied the name of the folder, to make sure that I don't spell it wrong or something. What am I doing wrong?

  8. Andrew
    Forum Moderator
    Posted 9 months ago #

    This is your Child Theme style.css file right http://programul-esl.ro/wordpress/wp-content/themes/20my11/style.css ?

    Why does it look like that, all on one line?

  9. leejosepho
    Member
    Posted 9 months ago #

    Exactly. Try this, and be sure your folder keeps this same name:

    /*
    * Theme Name: 20my11
    * Theme URI: http://programul-esl.ro/
    * Description: Child Theme for Twenty Eleven
    * Author: me
    * Author URI: http://programul-esl.ro/
    * Template: twentyeleven
    * Version: 0.1.0
    */
    @import url("../twentyeleven/style.css");
    /*
    * Theme customization begins below this line */
  10. Programul ESL
    Member
    Posted 9 months ago #

    @Andrew: Yes, that's the css. I have no ideea why it looks like that. In my editor (TopStyle that is) it did't look like that, it looked all tidy and organised like the code above.
    @leejoseph: I copied the code taht you gave me, and pasted it in a file calles style.css and uploaded it in the folder "20my11", that is , toghether with the folder "twentyeleven", in the "themes" folder.
    Then, I went to the dashboard, to appearance -> themes and clicked the refresh button. This is the result: http://programul-esl.ro/wordpress/easymedia/capture/ (click on the image to enlarge, I did't know how to add an image here on the forum).

  11. Andrew
    Forum Moderator
    Posted 9 months ago #

    Try deactivating all plugins and then see if your Child Theme style.css looks like that.

  12. leejosepho
    Member
    Posted 9 months ago #

    Yes, I would guess you have some kind of minification or cache plugin running.

  13. Programul ESL
    Member
    Posted 9 months ago #

    I have deactivated all the plungins from the site. The css still looks the same to me. You can check it at the link.
    I've deleted the cache from my browser (chrome) and hit the refresh button, and the css still looks the same.
    And the theme is still broken.
    By the way, I am so gratefull that you both took the time to help me and that you have the patience to keep looking into the problem. I hope we will solve the mistery in the end and get my a secure child theme that I can alter without risks. So what could I do next?

  14. Andrew
    Forum Moderator
    Posted 9 months ago #

    Your Child Theme style.css file looks like it has an asterisk after the 'template' name, is this something you've added?

  15. Programul ESL
    Member
    Posted 9 months ago #

    No, I haven't added a single thing.
    I think that is the asterisk that comes in front of every row, like in the code given by leejosepho. but because the css on the site has no rows, the asterisks come inbetween code.
    I am not an expert but I think that the /* */ signs are for commenting out a chunk of code. Should I remove the comment signs?

  16. leejosepho
    Member
    Posted 9 months ago #

    No, that code is okay, but you have something somewhere doing a minification of some kind that is putting everything out as a string.

  17. Andrew
    Forum Moderator
    Posted 9 months ago #

    Can you ask your hosting providers if they are minifying your CSS files?

  18. leejosepho
    Member
    Posted 9 months ago #

    In my editor (TopStyle that is) it did't look like that

    I think you might need to be using a plain-text editor.

  19. Programul ESL
    Member
    Posted 9 months ago #

    Is this putting everything on a string the problem that causes the theme to be broken?
    And if the do have some minification (which I will find out only on monday, as they do not work on the weekend), can I ask them to remove it? It's a payed host.

  20. leejosepho
    Member
    Posted 9 months ago #

    I would suspect your editor before suspecting your host.

  21. Programul ESL
    Member
    Posted 9 months ago #

    Could I find a work around it?

  22. leejosepho
    Member
    Posted 9 months ago #

  23. Programul ESL
    Member
    Posted 9 months ago #

    Oh my god! It worked! Oh my god! I am so excited!
    It WAS from my editor! I just copied the code in a text document and saved it as .css and it works!
    I am soooooooo thankfull guys! You are a site saver! I hope all this positive energy that I am radiating right now finds you guys somewhere and rewards you with whatever you wish, 'cause I almost gave up (and installed another theme to temper with in the mean time).
    THANK YOU!

  24. leejosepho
    Member
    Posted 9 months ago #

    Been there and done that, and you are most welcome!

    And now if you really want to get tricky, you can remove the @import line and use your previously-modified style.css like this:

    /*
    * Theme Name: 20my11
    * Theme URI: http://programul-esl.ro/
    * Description: Child Theme for Twenty Eleven
    * Author: me
    * Author URI: http://programul-esl.ro/
    * Template: twentyeleven
    * Version: 0.1.0
    */
    /*
    * All CSS code from previous style.css begins below this line */

    What you would be doing there is to *not* tell WordPress to use style.css from Twenty Eleven at all and to just use your own sheet. But if you had trouble with your previous sheet, you might not want to do that.

  25. Programul ESL
    Member
    Posted 9 months ago #

    I will keep the import command, because I want to keep only the alterations in the child-theme. This way I keep better track of what I change, in case I make stupid changes and I can't find where I've made that changes in the code.
    :) Thank you again!

Reply

You must log in to post.

About this Topic