• Hi
    The Bootstrap uses two CSS files (css/bootstrap[min].css & style.css) I wanted to change both so I used this code in the functions.php in the child theme (Thermory):

    function remove_thematic_actions() {
        remove_action( 'init', 'the_bootstrap_register_scripts_styles' );
    }
    add_action('init','remove_thematic_actions');
    
    function thermory_register_scripts_styles() {
    	if ( ! is_admin() ) {
    		$theme_version = _the_bootstrap_version();
    		$suffix = ( defined('SCRIPT_DEBUG') AND SCRIPT_DEBUG ) ? '' : '.min';
    
    		/**
    		 * Scripts
    		 */
    		wp_register_script(
    			'tw-bootstrap',
    			get_template_directory_uri() . "/js/bootstrap{$suffix}.js",
    			array('jquery'),
    			'2.0.3',
    			true
    		);
    
    		wp_register_script(
    			'the-bootstrap',
    			get_template_directory_uri() . "/js/the-bootstrap{$suffix}.js",
    			array('tw-bootstrap'),
    			$theme_version,
    			true
    		);
    
    		/**
    		 * Styles
    		 */
    		wp_register_style(
    			'tw-bootstrap',
    			get_stylesheet_directory_uri() . "/css/bootstrap.css",
    			array(),
    			'2.0.3'
    		);
    
    		wp_register_style(
    			'the-bootstrap',
    			get_stylesheet_directory_uri() . "/style.css",
    			array('tw-bootstrap'),
    			$theme_version
    		);
    	}
    }
    add_action( 'init', 'thermory_register_scripts_styles' );

    which (when I view page source) has created links to the new css in my child theme, however the css is still linking back to The Bootstrap parent theme despite the fact that: a) there is no link to it b) even when I delete the original code from the parent functions.php file it still links. The only way to stop it is by renaming the parent’s theme css file (bootstrap.min.css) then it links to the child theme css. I’d rather find out what I’m doing wrong than use this stop gap solution.
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • You have probably figured this out, but get_template_directory_uri() will return the parent theme’s directory.

    Use get_stylesheet_directory_uri() to include resources that are intended to be included in/over-ridden by the Child Theme.

    Thread Starter niallolaoghaire

    (@niallolaoghaire)

    Hi
    Sorry to take so long to get back & thanks for your reply duncanmoo, doing another site with the-bootstrap theme & got the same issue! I thought I was already using get_stylesheet_directory_uri() in the above code, am I missing something?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Replacing CSS in Child Theme’ is closed to new replies.