• Hi,

    First off thanks for such a great template! Im having a bit of an issue with creating a child theme.

    functions.php ///////////////////////////

    <?php

    if (! defined(‘WP_DEBUG’)) {
    die( ‘Direct access forbidden.’ );
    }

    add_action( ‘wp_enqueue_scripts’, function () {
    // This will load child style.css file
    wp_enqueue_style(‘chaplin-child’, get_stylesheet_uri());
    });

    style.css /////////////////////////////

    /*
    Theme Name: Chaplin Child
    Description: Customised child theme for Chaplin
    Author: n/a
    Author URL: n/a.com
    Template: chaplin
    Version: 1.0
    License: GNU General Public License v2 or later
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    Text Domain: ChaplinChild
    */

    /* Write here your own personal stylesheet */

    /* ——————————————————————————————— */
    /* 11. Entry Content
    /* ——————————————————————————————— */

    .entry-content {
    line-height: 1.5;
    /*max-width: 58rem;*/
    }

    Im not able to make any changes in the child css that are reflected on the site.

    Any help would be much appreciated, going nuts here.

    Cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mattbarb101

    (@mattbarb101)

    Any ideas people? Many thanks.

    Theme Author Anders Norén

    (@anlino)

    Hi @mattbarb101,

    Glad you like it! The code you posted should work, but it’s possible that the stylesheet gets enqueued after the Chaplin stylesheet, meaning the specificity of the CSS in your stylesheet needs to be higher to overwrite the Chaplin CSS.

    Another solution would be to increase the priority of the add_action(), so it runs after the equivalent function in Chaplin. You can do that by adding the number 20 to your add_action(), like so:

    add_action( ‘wp_enqueue_scripts’, function() {
    // This will load child style.css file
    wp_enqueue_style(‘chaplin-child’, get_stylesheet_uri());
    }, 20 );

    I can’t tell for sure that your enqueue code works in the first place without a link to the site, but give the above a try and see if it works for you.

    – Anders

    Thread Starter mattbarb101

    (@mattbarb101)

    Hi Anders,

    This seemed to do the trick.

    <?php 
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', PHP_INT_MAX );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'child-style', get_stylesheet_uri() );
    }
    ?>

    Many thanks!

    Agreed, thanks @anlino!

    I just setup a child theme and had a bit of trouble getting the CSS enqueued. This worked for me and follows the latest WordPress guidance. Hopefully, it will help others…

    <?php
    
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'child-style', get_stylesheet_uri(),
            array( 'chaplin-style' ), 
            wp_get_theme()->get('all') 
        );
    }

    Cheers!

    thanks,dashworth. this code worked well for me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Child for Chaplin’ is closed to new replies.