Child theme functions.php for dummies
-
Howdy,
I have a some very basic mods I need to perform in the functions.php file. I now want to move these modifications out into my child theme’s functions.php file.
This is the function in question which works fine in parent theme’s functions.php file.
public function get_branding() { $site_title = get_settings( 'blogname' ); $site_url = esc_url( get_site_url() ); $branding_lower = '<h2 class="branding-lower"><a href="/">xxxxxx</a></h2><h2 class="branding-department"><a href="'.$site_url.'">yyyyyy</a></h2>'; $branding = '<section class="branding"><h1 class="branding-upper"><a href="/">zzzzzz</a></h1><span class="branding-sep"> | </span>'.$branding_lower.'</section>'; return $branding; }
And when I place it in my child theme’s functions.php file I modify the function name and call it like this:
public function get_branding_child_ThemeName() { ...blah, blah, blah...
And I have created a copy of the theme file that calls this function and modified it to use the child theme name:
echo ThemeName::get()->get_branding_child_ThemeName();
The error I receive is not very helpful:
Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in C:\Users\me\Documents\Websites\test.dev\wp-content\themes\ThemeName-child\functions.php on line 27
And line 27 is this line in my childtheme’s functions.php file:
public function get_branding_child_ThemeName() {Any help would be greatly appreciated!
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
- The topic ‘Child theme functions.php for dummies’ is closed to new replies.