WordPress: Creating a child theme for Astra for using your own css/javascript

Hi, so let’s get started. After we installed Astra on our WP site, we go to the themes folder:

cd /var/www/html/wp-content/themes
mkdir astra-child

We need two files in here, style.css and functions.php. The style.css is just a simple data file, here is what I used for my theme here:

/*
 Theme Name: Astra Dropdown Jumper Child Theme
 Template:   astra
*/

and functions.php is:

<?php

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

function my_theme_enqueue_styles()
{
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

    # This is what I use for my css/scripts at the moment...
    wp_enqueue_style ( 'meuk-tmp-style',  'https://pub.stanzabird.nl/meuk/tmp/style.css' );
    wp_enqueue_script( 'meuk-tmp-script', 'https://pub.stanzabird.nl/meuk/tmp/script.js' );

}

Now when we go to Themes in WP, we should be able to select the new child theme, and test our style/script.

Leave a Comment

Your email address will not be published. Required fields are marked *