• [ Moderator note: moved to Fixing WordPress. ]

    Hello All!

    I am trying to make a child theme for the theme Illdy. I have read that it is faster and better to enque code from functions.php of the parent to the child which then will automatically upload style.css folders.

    My questions are, is this true or are there more steps needed to be taken?

    And also, what is the code needed to be put in the child’s function.php? Is it universal for all themes or is this theme specific?

    Thank You!
    Eric

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter edavenport

    (@edavenport)

    This is the code I have placed in the child theme’s function.php folder that I created on file manager through cPanel:

    // enqueue styles for child theme
    // @ https://digwp.com/2016/01/include-styles-child-theme/
    function example_enqueue_styles() {

    // enqueue parent styles
    wp_enqueue_style(‘parent-theme’, get_template_directory_uri() .’/style.css’);

    }
    add_action(‘wp_enqueue_scripts’, ‘example_enqueue_styles’);

    The theme is still not loading on the dashboard stating that the stylesheet is missing. How do I go about adding the style sheet using functions.php for a faster loading?

    Thank you!

    Hi @edavenport

    Have you checked this guide on Child Themes? I think it will answer most of your questions on Child Themes.

    Cheers!

    Thread Starter edavenport

    (@edavenport)

    Awesome, yes this is very helpful.

    One problem I’m running into with the file manager is that I have made a functions.php and a style.css under the new Illdy-child. Both of these are empty but 4 KB files. When I try to edit them I receive this message:

    You cannot open this file because it is either a directory or a file larger than one megabyte (1 MB). To edit the file, download it and use a local editor.

    But the download button is greyed out and inactive so I can’t download them either. Is it ok to compress them into a zip file?

    It’s totally ok to compress them into a zip file.

    But if they are empty it might be easier to just delete those two files and create two new ones.

    Thread Starter edavenport

    (@edavenport)

    I made zip files of functions.php and style.css in the child themes folder. In the functions.php I copy and pasted:

    <?php
    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()->get(‘Version’)
    );
    }
    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
    ?>
    
    and in the style.css I put:
    
    /*
    Theme Name: Illdy Child
    Theme URI: https://livingleashless.com/Illdy-child/
    Description: Illdy Theme
    Author: Colorlib
    Author URI: https://colorlib.com
    Template: Illdy
    Version: 1.0.35.2
    License: GNU General Public License v2 or later
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    Tags: blog, e-commerce, portfolio
    Text Domain: illdy
    */

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    But under appearance>themes I get this message:

    Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet.

    What else needs to be added to complete the child theme?

    Thank you!

    • This reply was modified 7 years, 10 months ago by edavenport.
    • This reply was modified 7 years, 10 months ago by edavenport.
    • This reply was modified 7 years, 10 months ago by bdbrown.

    Hi @edavenport

    Your functions.php looks fine, and the only required child theme file is style.css.

    I noticed that you have Template: Illdyand it should be Template: illdy with a lowercase i.

    Try to make that change and see if it works.

    Thread Starter edavenport

    (@edavenport)

    @xicoofficial thank you for the responses!

    I made the change to a lowercase i, but the problem still persists and am getting this same message:
    Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet.

    Do I need to make an index.php folder as well? I don’t understand why wordpress thinks it is a standalone theme when it has been enqueued to the parent?

    I also noticed that in the .php code I copied and pasted it had the generic ‘twenty fifteen’ examples, but I changed these to illdy but am still having problems.

    Hi,

    That is very strange.
    Since you are just starting the child theme I would advice to edit the sytle.css file with just this information:

    /*
    Theme Name:     Illdy Child
    Description:    Illdy Child Theme
    Author:         colorlib.com
    Template:       illdy
    */

    It should work, and then add the rest of the information line by line and notice when it breaks.

    You can do that with the funtions.php file as well.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Installing child theme using functions.php’ is closed to new replies.