Can’t get functions in the child theme functions.php to work
-
Hello everyone,
I’m working on tweaking a theme a bit. The child theme I created is clearly working as edits to my child theme footer.php appear as expected. However, either I’m doing something really obviously dumb, or it’s just not reading functions from the child function.php.
Here’s my child theme functions.php:
<?php add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); function enqueue_parent_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); } function writeChildMsg() { echo "Hello child function!"; }
When I call that function from the child footer.php file as so:
<?php writeChildMsg(); ?>
… it claims that the function is undefined. I’ve got PHP errors turned on, here’s the message:
Fatal error: Uncaught Error: Call to undefined function writeChildMsg() in /home/tikimojo/babyup.tikimojo.com/wp-content/themes/twentyseventeen-child/footer.php:90 Stack trace: #0 /home/tikimojo/babyup.tikimojo.com/wp-includes/template.php(730): require_once() #1 /home/tikimojo/babyup.tikimojo.com/wp-includes/template.php(676): load_template(‘/home/tikimojo/…’, true, Array) #2 /home/tikimojo/babyup.tikimojo.com/wp-includes/general-template.php(92): locate_template(Array, true, true, Array) #3 /home/tikimojo/babyup.tikimojo.com/wp-content/themes/twentyseventeen/single.php(47): get_footer() #4 /home/tikimojo/babyup.tikimojo.com/wp-includes/template-loader.php(106): include(‘/home/tikimojo/…’) #5 /home/tikimojo/babyup.tikimojo.com/wp-blog-header.php(19): require_once(‘/home/tikimojo/…’) #6 /home/tikimojo/babyup.tikimojo.com/index.php(17): require(‘/home/tikimojo/…’) #7 {main} thrown in /home/tikimojo/babyup.tikimojo.com/wp-content/themes/twentyseventeen-child/footer.php on line 90
Any idea what I’m doing wrong?
The page I need help with: [log in to see the link]
- The topic ‘Can’t get functions in the child theme functions.php to work’ is closed to new replies.