• Resolved drcontempo

    (@drcontempo)


    hey all, now that there’s a new method of using child themes with the enqueue script in functions.php instead of importing a new style.css:

    https://codex.www.ads-software.com/Child_Themes

    I’m not sure if the code in my functions.php is correct because I’ve added some template php files that I want overriding the parent theme. But It seems the the php files of the parent are still being used. The css of the child is taken though however.

    here’s my functions.php in my child theme folder:

    <?php
    function oneengine_enqueue_style() {

    wp_enqueue_style( ‘oneengine-parent-style’, get_template_directory_uri() . ‘/style.css’ );

    wp_enqueue_style( ‘oneengine-child-style’, get_stylesheet_uri() . ‘/style.css’ );
    }
    add_action( ‘wp_enqueue_scripts’, ‘oneengine_enqueue_style’ );
    ?>

    oneengine is the parent theme: is this right? or is there a url conflict?

    Thanks for any help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • I can’t quite tell from your description exactly what you;e hoping to do, and what’s working and what isn’t, esp, since you didn’t inlcude a URL for your site (so we could see if the stylesheets are loading or not). But can tell you this, the function get_stylesheet_uri() returns the file-path and filename or the active theme’s stylesheet:
    https://codex.www.ads-software.com/Function_Reference/get_stylesheet_uri

    So you should NOT be appending '/style.css' as that’ll result in a 404 URL like:
    /themes/[active-child-theme-folder}/style.css/style.css

    The get_stylesheet_directory_uri() does return the active theme’s directory name, so this is the URL of the stylesheet:
    get_stylesheet_directory_uri() . '/style.css'

    Hope this helps.

    Thread Starter drcontempo

    (@drcontempo)

    Thanks hearvox, that helped clarify things!

    Turns out though that I had it working, and my child theme template files are overriding the parent

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘using functions.php correctly for child themes’ is closed to new replies.