Title: Child theme functions.php for dummies
Last modified: August 31, 2016

---

# Child theme functions.php for dummies

 *  Resolved [mbcoulter](https://wordpress.org/support/users/mbcoulter/)
 * (@mbcoulter)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/child-theme-functionsphp-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](https://codex.wordpress.org/Forum_Welcome#Posting_Code).]

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [10 years, 2 months ago](https://wordpress.org/support/topic/child-theme-functionsphp-for-dummies/#post-7154244)
 * Hi!
 * Seeing this:
 *     ```
       public function get_branding()
       ```
   
 * Leads me to think the theme is using a class. The error you are receiving is 
   super helpful:
 * >  Parse error: **syntax error**, _unexpected_ ‘public’
 * Emphasis added, of course. What this means is you have an extra `public` in that
   line. I’m guessing you are not using this code in a class, correct? If you are
   really wanting to use that code then you would need to create an extending class.
   You can find some useful information here:
    [http://php.net/manual/en/keyword.extends.php](http://php.net/manual/en/keyword.extends.php)
 * In that class you would just use something like:
 *     ```
       class JMC_child extends ParentTheme_Class {
         public function get_branding(){
           // your code here
         }
       }
       ```
   
 * And then you would use something like:
 *     ```
       echo JMC_child::get_branding();
       ```
   
 * Keep in mind those are examples only to illustrate usage not actual working code.
 * If you are not too familiar with PHP classes, PHP.net does provide some useful
   information as well:
    [http://php.net/manual/en/oop4.php](http://php.net/manual/en/oop4.php)
 * Let us know if you have any further questions!
 *  Thread Starter [mbcoulter](https://wordpress.org/support/users/mbcoulter/)
 * (@mbcoulter)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/child-theme-functionsphp-for-dummies/#post-7154258)
 * Hi Jose,
 * Thank you SO VERY MUCH! Your comments were very close to the perfect fix. I found
   this boilerplate included at the bottom of my parent theme’s functions.php file:
 *     ```
       //Start child theme code.
   
       function MYPARENTTHEME_CHILD_THEME() {
         class MY_CHILD_THEME extends MYPARENTTHEME {
           //Define overrides and new functionality here.
         }
         new MY_CHILD_THEME();
       }
       ```
   
 * I dropped this into my child theme’s functions.php file (with my theme’s specific
   names) and it seems to have worked!
 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [10 years, 2 months ago](https://wordpress.org/support/topic/child-theme-functionsphp-for-dummies/#post-7154260)
 * Awesome! Glad to see it worked out for you! 😀

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Child theme functions.php for dummies’ is closed to new replies.

## Tags

 * [child theme functions.php](https://wordpress.org/support/topic-tag/child-theme-functions-php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/child-theme-functionsphp-for-dummies/#post-7154260)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
