As I said, you have a few problems with this code.
- closing bracket
}
for no reason. - a extra
,
in thewp_enqueue_script
at the end add_action( 'wp_enqueue_scripts', 'my_scripts_method');
is insidemy_scripts_method
function
This is your current code with some formating and comments to show the problematic code sections.
<?php
/**
* Astra Child Theme functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Astra Child
* @since 1.0.0
*/
/**
* Define Constants
*/
define( 'CHILD_THEME_ASTRA_CHILD_VERSION', '1.0.0' );
/**
* Enqueue styles
*/
function child_enqueue_styles() {
wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );
// this closing bracket is not needed
}
function my_scripts_method() {
// this functions contains , at the end, not needed
wp_enqueue_script('custom-script',get_stylesheet_directory_uri() . '/js/custom_script.js',);
// this add_action cannot be inside its own the callback function
add_action( 'wp_enqueue_scripts', 'my_scripts_method');
}
This is the corrected code.
<?php
/**
* Astra Child Theme functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Astra Child
* @since 1.0.0
*/
/**
* Define Constants
*/
define( 'CHILD_THEME_ASTRA_CHILD_VERSION', '1.0.0' );
/**
* Enqueue styles
*/
function child_enqueue_styles() {
wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );
function my_scripts_method() {
// this functions contains , at the end, not needed
wp_enqueue_script('custom-script',get_stylesheet_directory_uri() . '/js/custom_script.js');
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method');