• 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]

Viewing 2 replies - 1 through 2 (of 2 total)
  • check to make sure the file is named functions.php. If it function.php it will not work. One place in your post you referred to it as function.php and in another as functions.php.

    • This reply was modified 4 years, 6 months ago by mrtom414.
    Thread Starter tikimojo

    (@tikimojo)

    The child file is definitely named “functions.php”. (yeah, I can see that happening)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can’t get functions in the child theme functions.php to work’ is closed to new replies.