Instead of bogging down my child theme's functions.php
file, I would like to have a separate .php file that has various functions, that I can call within functions.php
(and in other files).
I have created my-custom-functions.php
within my child theme, where the functions.php
lives.
Here's the folder structure:
wp-content
themes
grow-minimal-child
functions.php
my-custom-functions.php
Code for my-custom-functions.php
:
<?php
function js_log($msg){
return "<script type='text/javascript'>alert('$msg');</script>";
}
echo js_log("Hello!");
And the first few lines of functions.php
:
<?php
include_once(get_theme_roots() . '/grow-minimal-child/rs-custom-functions.php');
But, when I load any page, I get this error:
Warning: include_once(/themes/grow-minimal-child/my-custom-functions.php): failed to open stream: No such file or directory in /opt/bitnami/apps/wordpress/htdocs/wp-content/themes/grow-minimal-child/functions.php on line 2
What do I need to fix, it looks like the include_once
is looking for functions.php
?