Theme with Child Themes
-
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
- The topic ‘Theme with Child Themes’ is closed to new replies.