WordPress.org

Ready to get started?Download WordPress

Forums

[Theme: Sundance] Can't create child theme! (10 posts)

  1. JFlybring
    Member
    Posted 1 year ago #

    Hello everyone!

    I'm pretty new at this WordPress business, and I'm working hard on learning how to use CSS, PHP, FTP and all other acronyms. :-P

    I have encountered a frustrating challenge that I'm hoping someone here would be able to help me with: I can't create a child theme for the Sundance theme.

    I have done the following:
    - I created a new folder called 'sundance-child' within the /wp-content/themes/ folder.
    - I put in the newly created folder a copy of 'style.css', 'rtl.css' and 'functions.php' from the original 'sundance' theme folder, all identical to the parent files.

    When I tried loading the new child theme, the following message appeared:

    Fatal error: Cannot redeclare sundance_set_content_width() (previously declared in /hermes/bosweb/web034/b342/ipg.johanflybringcom/wp-content/themes/sundance-child/functions.php:16) in /hermes/bosweb/web034/b342/ipg.johanflybringcom/wp-content/themes/sundance/functions.php on line 30

    What can I do to fix that? I tried changing some bits of code in the files but it either didn't work or it just created new error messages (however still "cannot declare") pointing at other functions/files.

    Any help would be hugely appreciated. Thank you.

  2. Jesper Johansen (jayjdk)
    Member
    Posted 1 year ago #

    Try removing all the content from the child theme functions.php

  3. JFlybring
    Member
    Posted 1 year ago #

    I tried—after reading about it on a website—to add the following:

    if(!function_exists('sundance_set_content_width'))
    {

    before
    function sundance_set_content_width() {
    in functions.php.

    But this didn't seem to work.

    I'll try as you suggest to remove everything, and I'll get back with the results...

  4. JFlybring
    Member
    Posted 1 year ago #

    It worked, thank you!

    No more error messages, however the theme has gone back to default colour and no header... can't see any other major changes yet...

    Will a blank 'functions.php' file not affect future customisation, such as new functions, etc.?

  5. JFlybring
    Member
    Posted 1 year ago #

    My header images are still in my media library, but they are not visible on the 'Custom Header' page on the dashboard (under 'Appearance'). Do I need to re-upload them? Although that would give me duplicates...

    Also, my favicon has disappeared and I can't figure out how to make it appear again.

    Is this due to deleting the functions.php content, or do I need to do something else?

    Thanks again.

  6. - I put in the newly created folder a copy of 'style.css', 'rtl.css' and 'functions.php' from the original 'sundance' theme folder, all identical to the parent files.

    You do not make copies of those files (well, maybe the rtl.css I'll check that one) you create a new style.css that imports the parent theme's CSS. Same with the functions.php, the child theme gets a new empty one to start with.

    http://codex.wordpress.org/Child_Themes

  7. JFlybring
    Member
    Posted 1 year ago #

    Sorry I mislead you a little bit there, I did indeed copy the files but I modified them to link back to the parent theme and to import its CSS.
    For example, in the child 'style.css' I used:
    @import url("../sundance/style.css");

    The 'functions.php' file only seems to cooperate if I delete all its content.

    I just tried starting the process again and only left the essential information in the files (as advised on that link you posted, thank you). But it didn't seem to change anything; I'm still having issues with the headers and the favicon... I seem to have a problem linking the child theme back to the parent theme properly.

  8. *Looks at HTML source*

    Try a more minimal wp-content/themes/sundance-child/style.css instead of that one.

    http://pastebin.com/9CHWpUYY

    Also remove any other files in your wp-content/themes/sundance-child directory. That will start you with as basic a child theme as you can get with Sundance.

    If you want to add your own functions to the child theme's add them after this one line in wp-content/themes/sundance-child/functions.php

    <?php

    Which for a child theme is the only thing you need to start. ;) Don't worry about functions in the parent functions.php file. That copy will get loaded after the child theme's copy so you don't need to reproduce anything in the parent version.

  9. JFlybring
    Member
    Posted 1 year ago #

    Thank you, that makes things a bit clearer for me. :-)

    So the rtl.css file is not needed in the child theme directory? I added it just in case, following the instructions here http://codex.wordpress.org/Child_Themes.

    I had used a code for the favicon in the header.php file in the parent theme, but I couldn't get it to work in the child theme; so I decided to add the favicon via a function in the function.php file instead. And it seems to work, which is good.

    The theme headers I had added in the parent theme are still in the media library but no longer selectable as headers. Nevermind, I guess I'll just reupload them through the child theme and delete the old ones. :-)

    So all in all it seems to work fine now, and I've got a slightly better grip of how to work with a child theme. Thank you very much. :-)

  10. You're welcome, glad you're getting the hang of it.

    So the rtl.css file is not needed in the child theme directory?

    Probably is, especially if the Codex article says so. ;)

Topic Closed

This topic has been closed to new replies.

About this Topic