badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Issues with setting up child-theme

Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #75654
    sjoerd
    Participant

    Hello ThemeHorse,

    I would like to alter a couple of things so I need to create a child theme – I created for my current site a child-theme too so I’m familiar with it, but somehow I seems to be missing something creating one for newscard pro.

    According to the WordPress codex I should enqueue the parent stylesheet but when I do that the site looks terrible
    Here is part of my functions.php

    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    function enqueue_parent_styles() {
    	$parent_style = 'newscard-style'; 
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'newscard-child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    

    Here is my styles.css

    
    /*
    Theme Name: NewsCard Pro Child
    Theme URI: https://ThemeHorse.com
    Description: Child theme for NewsCard Pro.
    Author: sjoerd at boxer.gs
    Author URI: http://k1600gt.nl/
    Template: newscard-pro
    Version: 1.0
    */
    
    .wpgpxmaps,
    .rl-gallery-link img,
    .wp-caption img {
    	background-color: #eee;
    	border: 1px solid #ccc;
    	padding: 4px;
    }
    

    I can activate the child theme perfectly and the two style.css files are in the html output:

    
    link rel='stylesheet' id='newscard-style-css'  href='http://10.0.1.101/wp-content/themes/newscard-pro/style.css?ver=5.3.2' type='text/css' media='all'
    link rel='stylesheet' id='newscard-child-style-css'  href='http://10.0.1.101/wp-content/themes/newscard-pro-child/style.css?ver=1.0' type='text/css' media='all'
    

    If I use the old methode using @import then is works but wordpress does not advice it

    Please advice or provide me (us) a working set.

    Regards,
    Sjoerd

    #75988

    Hi Sjoerd,

    You have to maintain all of the parent theme dependencies as this theme have more than 1 CSS file. So you need to load Bootstrap CSS before parent theme style.css and then child theme style.css. Please use below code an let us know.

    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    function enqueue_parent_styles() {
    	$parent_style = 'newscard-style';
    	wp_enqueue_style( 'bootstrap-style', get_template_directory_uri().'/assets/library/bootstrap/css/bootstrap.min.css', array(), '4.0.0');
    	wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'newscard-child-style',
    		get_stylesheet_directory_uri() . '/style.css',
    		array( $parent_style ),
    		wp_get_theme()->get('Version')
    	);
    }

    Thank you!

    #76049
    sjoerd
    Participant

    Excellent!

    I was not aware I had to enqueue bootstrap as well.

    Regards
    Sjoerd

    #76078

    Hell Sjoerd,

    Bootstrap should load before style.css so you need to enqueue it again in child theme to load it first.

    Thank you!

    #76081
    sjoerd
    Participant

    Yes,

    It’s working now.

    Thanks
    Sjoerd

    #76107

    Welcome anytime Sjoerd.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.