Support » Themes and Templates » why I can never create a child theme?

  • I’m trying to create a child theme without using the old @import but it never works, I’ve tried with several themes from several developers and the only way I can create the child theme is by giving up and using @import..

    I’ve tried adding to function.php this code:

    add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
    function theme_enqueue_styles() {
    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’)
    );
    }

    and also this code:

    add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
    function theme_enqueue_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
    }

    and when I try to activate it, I get The parent theme is missing. Please install the “Felicity” parent theme. message even thou the theme Felicity (or whatever themes I’ve tried) are all installed and the spell is correct..

    Am I missing something? Is there something in the function I’m supposed to add?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • WPyogi

    (@wpyogi)

    Forum Moderator

    In most cases, the functions.php file should have just this:

    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
    }

    Do you have the php tag at the top?

    Moderator stephencottontail

    (@stephencottontail)

    Another thing to check is the Template: line in your child theme’s style.css. The Template: line needs to contain the name of the folder that contains the parent theme, and capitalization matters.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘why I can never create a child theme?’ is closed to new replies.