• Hi. As you know I enjoy using your Aaron theme on my site christianboyce.com. I have a few ideas for modifications which I would like to make myself, small things that make the site slightly different than “standard Aaron.” My understanding is I should make and use a child theme, so my changes (which are css) will remain when Aaron is updated.

    The problem is, when I use a child theme, no change to the child theme’s styles.css take effect. I got some help on this and it appears that Aaron’s styles.css loads LAST, so it overrides whatever I do in the child theme’s css. Here is what I was told:

    Yes. The code below ( from Aaron’s functions.php ) first queues the child theme stylesheet ( “stylesheet_uri” ) and then if it is a child theme, it queues the parent theme stylesheet (“template_uri”).

    This will cause the parent styles to take priority over the child theme styles, defeating the purpose of using a child theme in the first place.

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    function aaron_scripts() {
    	wp_enqueue_style( 'aaron-style', get_stylesheet_uri(), array( 'dashicons' ) );
    	wp_enqueue_style( 'aaron-fonts', aaron_fonts_url(), array(), null );
    	wp_enqueue_style( 'open-sans' );
    
    	wp_enqueue_script( 'aaron-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
    	wp_enqueue_script( 'aaron-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20120206', true );
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    		wp_enqueue_script( 'comment-reply' );
    	}
    
    	if ( is_page_template( 'templates/grid.php' ) ) {
    		wp_enqueue_script( 'masonry' );
    		wp_enqueue_script( 'aaron-grid', get_template_directory_uri() . '/js/grid.js', array(), true );
    	}
    
    	 /* If using a child theme, auto-load the parent theme style. */
    	if ( is_child_theme() ) {
    		wp_enqueue_style( 'parent-style', trailingslashit( get_template_directory_uri() ) . 'style.css' );
    	}
    }

    So… first of all, I wonder if this behavior is intentional. I am using Aaron 2.7. Second of all, I wonder if I can change it myself so the Child Theme’s styles load last.

    As always, thank you!

    c

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Carolina Nymark

    (@poena)

    Hi
    Yes you are right, I have placed them in the wrong order. The if .. is_child_theme().. must be above the aaron-style.

    Does this mean that you figured out how to change the sidebar width? I did not have time to reply.

    In my child theme, I include a functions.php file. It can add more functions and modify parent theme functions.

    To ensure that the child theme loads last, use the following enqueue code in the child theme’s functions.php file:

    <?php
    /**
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    * Enqueu the parent and child theme stylesheets//
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    */
    function theme_enqueue_styles() {
    
        $parent_style = 'parent-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 )
        );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    ?>

    Thread Starter christianboyce

    (@christianboyce)

    Hi Carolina. No, I have not figured out how to change the sidebar width, and I’m not sure where to go about making the change– have you made any changes to the theme that would allow a child theme to work in the normal way?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Theme with Child Themes’ is closed to new replies.