[Resolved] Child theme not working

This topic contains 6 replies, has 2 voices, and was last updated by  Andrew Misplon 10 months, 2 weeks ago.

  • Author
    Posts
  • #8519

    DigitalMakers
    Participant

    Hi,

    We are working on a new website with a fresh install of WordPress 4.9.1 and Polestar theme 1.1, but the child theme is not working.

    These are the files:

    functions.php

    <?php
    /**
     * Enqueue the parent theme stylesheet.
     */
    function polestar_child_scripts() {
        wp_enqueue_style( 'polestar-parent-style', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'polestar_child_scripts', 8);
    
    function customScripts()
    {
        wp_enqueue_style( 'font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
        wp_enqueue_script( 'custom-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array ( 'jquery' ), '1.0', true );
    }
    add_action( 'wp_enqueue_scripts', 'customScripts' );

    style.css

    /*
    Theme Name: Polestar Child
    Author: Puro
    Author URI: https://purothemes.com/
    Theme URI: https://wordpress.org/themes/polestar/
    Description: Polestar Child Theme
    Version: 1.0.0
    Template: polestar
    Text Domain: polestar-child
    Domain Path: /languages/
    */

    The source code only charges the parent style.css but twice, one by this functions.php and another that is minified.

    Could you please help with the problem? Thanks!

    #8520

    Andrew Misplon
    Keymaster

    Hi 🙂

    Thanks for posting.

    If possible, please, can you share a link to a page with the problem so I can inspect the specific CSS rule you’re having trouble with and take a look at the file setup live. Everything above looks normal so it’ll be helpful to take a look at a specific customisation you’re having a trouble with.

    #8529

    DigitalMakers
    Participant
    This reply has been marked as private.
    #8532

    DigitalMakers
    Participant
    This reply has been marked as private.
    #8533

    Andrew Misplon
    Keymaster

    Thanks for the update and for raising this. Here, the parent is doing things slightly differently: https://github.com/purothemes/polestar/blob/master/functions.php#L152. The unminified version still has to be included for WP directory purposes. The demo child theme is incorrect, sorry about that and thanks again for raising this. Please, try changing your child functions file to:

    <?php
    
    /**
     * Enqueue theme scripts and styles.
     */
    function polestar_child_scripts() {
    
    	// Child theme stylesheet.
    	wp_enqueue_style( 'polestar-child', get_stylesheet_directory_uri() . '/style.css' );
    
    	// Font Awesome.
    	wp_enqueue_style( 'font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
    
    	// Custom Scripts
    	wp_enqueue_script( 'polestar-child-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array( 'jquery' ), '1.0', true );	 
    
    }
    add_action( 'wp_enqueue_scripts', 'polestar_child_scripts', 8 );

    Let me know how that goes and we’ll take it from there 🙂

    #8534

    DigitalMakers
    Participant

    Hi Andrew,

    it solves the problem with the child theme. Thanks for the solution!

    #8535

    Andrew Misplon
    Keymaster

    Awesome 🙂 Glad to hear that did the trick and sorry for the hassle. Chat soon, cheers!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Scroll to top