Title: Adding Code to functions.php in Child Theme
Last modified: August 31, 2016

---

# Adding Code to functions.php in Child Theme

 *  [sbgolledge](https://wordpress.org/support/users/sbgolledge/)
 * (@sbgolledge)
 * [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/)
 * Hi,
    I’ve added a snippet of code to my functions.php file in my Twenty-Twelve
   Child Theme, but it has come up as a parse error. I know I’m doing something 
   wrong, can anyone advise? I’ve added it like this and saved…
 *     ```
       <?php
       add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
       function theme_enqueue_styles() {
           wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
   
       }
       ?>
   
       <?php if ( is_search() || is_archive() || is_author() || is_tag() || is_home() ) : // Only display Excerpts ?>
       ```
   
 * Many thanks in advance,
 * Stuart

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

 *  [Clarion Technologies](https://wordpress.org/support/users/clarionwpdeveloper/)
 * (@clarionwpdeveloper)
 * [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/#post-7384304)
 * Hi,
 * You are missing the end of If tag.
    Please use the code below and see if it works
   for you.
 * >  <?php
   >  add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ ); function
   > theme_enqueue_styles() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri().‘/
   > style.css’ );
   > }
   >  ?>
   > <?php if ( is_search() || is_archive() || is_author() || is_tag() || is_home())://
   > Only display Excerpts
   >  endif; ?>
 * Thanks
 *  Thread Starter [sbgolledge](https://wordpress.org/support/users/sbgolledge/)
 * (@sbgolledge)
 * [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/#post-7384307)
 * Many thanks for your quick response!
 * I’ve made the ammendment and now get this on the top of my website?
 * Warning: session_start(): Cannot send session cache limiter – headers already
   sent (output started at /home1/karmafree/public_html/wp-content/themes/twentytwelve-
   child/functions.php:9) in /home1/karmafree/public_html/wp-content/plugins/custom-
   contact-forms/classes/class-ccf-form-handler.php on line 587
 * I’ve now removed the code again. Any thoughts? I’d ideally like the site to display
   like this [http://karma-free-life.com/?s=garlic](http://karma-free-life.com/?s=garlic)(
   I’ll of course add featured tiles) with perhaps ‘read more’ links, once I get
   the basics sorted.
 * Many thanks,
 * Stuart
 *  [Clarion Technologies](https://wordpress.org/support/users/clarionwpdeveloper/)
 * (@clarionwpdeveloper)
 * [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/#post-7384417)
 * Hi,
 * Please change the above code which was previously posted by us as follows:
 * >     ```
   >     <?php
   >         add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
   > 
   >         function theme_enqueue_styles() {
   >         wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
   > 
   >         }
   > 
   >       if ( is_search() || is_archive() || is_author() || is_tag() || is_home() ) :
   >             // Only display Excerpts
   >       endif;
   >         ?>
   >     ```
   > 
 * Please let us know if it solves your problem.
 * Thanks
 *  Thread Starter [sbgolledge](https://wordpress.org/support/users/sbgolledge/)
 * (@sbgolledge)
 * [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/#post-7384459)
 * Hi, Clarion Technologies,
 * Many thanks, again, but, no, this had no effect in adding excerpts to my site.
 * I’m totally baffled!
 * Stuart
 *  [girlieworks](https://wordpress.org/support/users/girlieworks/)
 * (@girlieworks)
 * [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/#post-7384484)
 * [@sbgolledge](https://wordpress.org/support/users/sbgolledge/): If I’m understanding
   what your aim is here, then you need something more than just this comment:
 * `// Only display Excerpts`
 * For example, you’d need [`<?php the_excerpt(); ?>`](https://developer.wordpress.org/reference/functions/the_excerpt/)
   there in order to actually display an excerpt.

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

The topic ‘Adding Code to functions.php in Child Theme’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [girlieworks](https://wordpress.org/support/users/girlieworks/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/adding-code-to-functionsphp-in-child-theme/#post-7384484)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
