Creating Child Theme: Two different functions.php instructions
-
I am in the process of making a child theme for my Theme, flatsome. I have found 2 separate sources for this, with seemingly different code instructions. The first being from these forums, another from my domain and host provider, hostinger:
https://developer.www.ads-software.com/themes/advanced-topics/child-themes/
https://www.hostinger.com/tutorials/how-to-create-wordpress-child-themeI had both instructions up side by side to make sure I understand. With respect to the developer wordpress post, I am on step 3. The functions.php code is different from the 2 sources, and I would really appreciate some guidance. I see a lot of similarities but a lot of differences.
// developer.wordpress
<?php add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parenthandle' ), wp_get_theme()->get('Version') // this only works if you have Version in the style header ); }
// hostinger tutorials
<?php add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); function enqueue_parent_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); } ?>
Here is my style.css code in my child theme:
/* Theme Name: Flatsome Child Theme URL: https://tomitechnologies.com/wp-admin/themes.php?theme=flatsome Description: Flatsome Child Theme Author: Jack Nicholson Author URL: https://tomitechnologies.com Template: flatsome Version: 3.12.0 Text Domain: flatsome-child */
EDIT: So I’ve included the differences which I don’t understand:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wordpress code employs:
– ‘child-style’ instead of ‘parent-style’
– get_stylesheet_uri() instead of get_template_directory_uri().’/style.css’
– contains an additional parameters:
– array( ‘parenthandle’ )
– wp_get_theme()->get(‘Version’)So in-case I wasn’t clear, I want to know which I should use for my flatsome child theme, or a combination thereof.
- The topic ‘Creating Child Theme: Two different functions.php instructions’ is closed to new replies.