Viewing 1 replies (of 1 total)
  • Superjmr, I noticed this as well. However, not all themes will cause this. I found at least one theme that worked properly with the original code:

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        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')
        );
    }

    ____

    For a theme that has the stylesheet duplicated, replace the bit of code in the new child-themes functions.php with this.

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }

    If you are looking to use this on a multisite you might change the plugin template that creates the child themes function.php – /plugins/one-click-child-theme/templates/functions.php – simply replace the bit of code as the example above shows.

    It is not good practice to overwrite core plugin files, however this plugin has not been updated in over a year and is such a basic plugin I decided to adapt it for my needs.

    If you want to get fancy with the child-theme style sheet to include all the meta a normal theme does, modify this in the /templates/child-theme-css.php

    /*
    Theme Name:     <?php echo $new_theme_title, "\n"; ?>
    Description:    <?php echo $new_theme_description, "\n"; ?>
    Author:         <?php echo $new_theme_author, "\n"; ?>
    Template:       <?php echo $parent_theme_template, "\n"; ?>
    Author URI:   	<?php echo 'https://your.com', "\n"; ?>
    Version:      	<?php $my_theme = wp_get_theme();echo $my_theme->get( 'Name' ) . " is version " . $my_theme->get( 'Version' ), "\n";?>
    License:      	<?php echo 'https://url-to-theme-license.com/' . $parent_theme_template . '/style.css', "\n"; ?>
    License URI:  	<?php echo '^', "\n"; ?>
    Tags:         	<?php echo implode(", ", $my_theme->get( 'Tags' )), "\n"; ?>
    Text Domain:  	<?php echo $parent_theme_template. '-child' , "\n"; ?>
    */
Viewing 1 replies (of 1 total)
  • The topic ‘my css styles are duplicated’ is closed to new replies.