Child theme doesn’t work
-
Hi,
I’m trying to create a child theme for customizing Woocommerce registration fields. However, neither my child style.css nor functions.php do not work.Below is my style.css:
/* Theme Name: Shopper Child Template: shopper */ * { background-color: red !important; }
I added a background color to all elements to see if the child theme works, I refreshed the site, but nothing changed.
Below is my functions.php file :
<?php function shopper_child_enqueue_styles() { $parent_style = 'shopper-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/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', 'shopper_child_enqueue_styles' ); /** * Add new register fields for WooCommerce registration. * * * @return string Register fields HTML. */ function wooc_extra_register_fields() { ?> <p class="form-row form-row-wide"> <label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" /> </p> <p class="form-row form-row-wide"> <label for="reg_billing_address_1"><?php _e( 'Address', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="billing_address_1" id="reg_billing_address_1" value="<?php if ( ! empty( $_POST['billing_address_1'] ) ) esc_attr_e( $_POST['billing_address_1'] ); ?>" /> </p> <p class="form-row form-row-wide"> <label for="reg_billing_postcode"><?php _e( 'postcode', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="billing_postcode" id="reg_billing_postcode" value="<?php if ( ! empty( $_POST['billing_postcode'] ) ) esc_attr_e( $_POST['billing_postcode'] ); ?>" /> </p> <p class="form-row form-row-wide"> <label for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" /> </p> <?php } add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' ); ?>
I think this isn’t the theme’s problem because I tried creating a child theme to 2 sites using different themes but neither of them worked.
The location of the folder is correct: I created a child theme folder where other themes are, and inside the folder, there are two files: style.css and functions.php.
If I create a plugin and add my code to it, it works. But I prefer using a child theme to installing a plugin, so I want to know why my child themes don’t work.
Thank you in advance.
- The topic ‘Child theme doesn’t work’ is closed to new replies.