• Resolved featherhead

    (@featherhead)


    Hello,

    I am trying to set up a child theme for the WooCommerce Storefront theme. I have done child themes before without too much trouble, but for some reason, this one is very difficult. I have narrowed it down to what happens when I put the Template in the header.

    Current header in my style.css is this:

    /*!
    Theme Name: Storefront-child
    Theme URI: https://woocommerce.com/storefront-child
    Author: WooThemes
    Author URI: https://woocommerce.com/
    Description: Storefront child theme
    Version: 2.2.5
    License: GNU General Public License v2 or later
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    Template: storefront
    Text Domain: storefront-child
    Tags: e-commerce, two-columns, left-sidebar, right-sidebar, custom-background, custom-colors, custom-header, custom-menu, featured-images, full-width-template, threaded-comments, accessibility-ready, rtl-language-support, footer-widgets, sticky-post, theme-options

    When I activate the child theme, the following error comes up:

    Fatal error: Cannot redeclare storefront_is_product_archive() (previously declared in /home1/lharkins/mu-tang.com/wp-content/themes/storefront-child/inc/storefront-functions.php:22) in /home1/lharkins/mu-tang.com/wp-content/themes/storefront/inc/storefront-functions.php on line 31

    I did a lot of messing around to try and figure out what the problem is, and finally I started with a fresh directory and started changing things line by line, checking each time I changed something. The problem seems to be the Template line. Problems didn’t happen until I put that line in, and if I take the Template line out of the style.css, things appear to be fine.

    I don’t know much code, so I don’t know what this error is or how to fix it.

    Can you help?

    Thanks

    • This topic was modified 7 years, 4 months ago by featherhead.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Well PHP tells you you are redeclaring storefront_is_product_archive. So you are calling it twice and that causes issues. On line 22 of file /home1/lharkins/mu-tang.com/wp-content/themes/storefront-child/inc/storefront-functions.php of your child theme you added it. In the parent theme it is on line 31 of file /home1/lharkins/mu-tang.com/wp-content/themes/storefront/inc/storefront-functions.php it is already in use. So no need to do things twice..

    As you are new to this all I suggest you use this boilerplate Storefront child theme and focus on needed CSS changes only.

    If you do need code changes only add functionality for that, don’t clone the parent. The latter can cause errors like you are experiencing. Use the boilerplate mentioned and added functionality as needed.

    NB Do also check official documentation on Child themes

    • This reply was modified 7 years, 4 months ago by Rhand.
    • This reply was modified 7 years, 4 months ago by Rhand.
    Thread Starter featherhead

    (@featherhead)

    Ah! Thanks very much! I didn’t know there was already a child theme out there. I will give that a try.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Error with child theme’ is closed to new replies.