Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1101795

    Hi
    On wordpress.org the following recommendation:

    3. Enqueue stylesheet #
    The final step is to enqueue the parent and child theme stylesheets.
    Note: In the past, the common method was to import the parent theme stylesheet using @import; this is no longer the recommended practice, as it increases the amount of time it takes style sheets to load. Plus it is possible for the parent stylesheet to get included twice.

    And the sample for that (twenty fifteen):
    <?php
    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
    function my_theme_enqueue_styles() {
    $parent_style = ‘parent-style’; // This is ‘twentyfifteen-style’ for the Twenty Fifteen theme.
    wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_style( ‘child-style’,
    get_stylesheet_directory_uri() . ‘/style.css’,
    array( $parent_style ),
    wp_get_theme()-&gt;get(‘Version’)
    );
    }
    ?>

    In your download on

    for a child theme there is nothing written in the functions.php
    Is that an old download? Or: I don’t have to include the CSS files of the enfold theme like that – I can use the child-theme folder as it is on your documentation page …
    Thanks for your answer
    H

    • This topic was modified 5 years, 6 months ago by webmanu.
    #1101916

    Hi webmanu

    I use a child theme for all of my projects. Coming to your questions:

    for a child theme there is nothing written in the functions.php. Is that an old download?

    Possibly. The code I use in functions.php is at the least the following (very similar to the one you posted above):

    <?php
    function my_theme_enqueue_styles() {
    
        $parent_style = 'parent-style'; // This is 'enfold-style' for the Enfold theme.
    
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    ?>

    I don’t have to include the CSS files of the enfold theme like that – I can use the child-theme folder as it is on your documentation page…

    I would include it like I described above. In addition to that, you should have a file style.css as well. This file should have at least something like that:

    /*
    Theme Name: Enfold Child
    Theme URI: https://kriesi.at
    Description: Child theme for [your project name here]
    Author: webmanu
    Author URI: https://webmanu.com
    Template: enfold
    Version: 1.0.0
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    */

    Important: Do not change the value “enfold” for “Template”. Otherwise WordPress will not recognize that you built a child theme based on Enfold.

    Last but not least:
    If you want a nice snapshot of your child theme if you head over to “Design” in the backend, just upload a file called screenshot.png (700x467px) to your child theme folder.

    I hope that helps.

    Cheers and have fun!
    Michael

    #1102472

    Hi Michael
    I don’t understand the fact that on kriesi.at
    Child Theme in your documentation site
    your recommendation for the functions.php in your answer is not included in the child theme you offer for download.
    Greets
    Heinz

    #1102906

    Hi,

    If you are adding CSS code to enfold-child/style.css and Enfold Child is the active theme you need not do anything at all.

    This file is enqueued by default as the last one.

    Best regards,
    Günter

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