1
votes

I am trying to create a Wordpress child theme and have been visiting the following website:https://codex.wordpress.org/Child_Themes.

On this website it says that I have to create two files, of which the style.css is clear, My question is about functions.php. It says at some point that I have to copy paste the following text in the newly created functions.php file:

<?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' );
?>

I wonder where in this php file I have to make modifications i.e. where do I put the name of my theme in the functionality?

Thanks,

Naveen

2

2 Answers

1
votes

First You need to understand how the child theme actually works. Child theme uses the files of its parent theme, and generate an another style.css for child theme. Generally, people develop a new child theme for design customization. Now if you wants to add other functionality or change the default one you will need to add it in functions.php.

Here in this code you are adding style.css file of parent theme as well as child theme.

If you still face problem there is a plugin to create child theme.

https://wordpress.org/plugins/one-click-child-theme/

Install plugin and now you just need to select the parent theme and name of your new child theme and you are good to go.

0
votes

Add action or filter hooks can be done by functions.php

Please add wp_enqueue_scripts code in functions.php