Title: Adding functions to Onepress child theme functions.php causes errors
Last modified: December 19, 2019

---

# Adding functions to Onepress child theme functions.php causes errors

 *  [laukejas](https://wordpress.org/support/users/laukejas/)
 * (@laukejas)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-functions-to-onepress-child-theme-functions-php-causes-errors/)
 * I downloaded and installed Onepress child theme, activated it, and copied the
   settings to it via Recommended Actions. With default functions.php, it works.
   But now I want to add a function that modifies the behavior of woomcommerce plugin,
   so my functions.php looks like this:
 *     ```
       <?php
   
       /**
   
        * OnePress Child Theme Functions
   
        *
   
        */
   
       function woocommerce_after_shop_loop_item_title_short_description() {
       	global $product;
       	if ( ! $product->post->post_excerpt ) return;
       	?>
       	<div itemprop="description">
       		<?php echo apply_filters( 'woocommerce_short_description', $product->post->post_excerpt ) ?>
       	</div>
       	<?php
       }
       add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_after_shop_loop_item_title_short_description', 5);
   
       /**
   
        * Enqueue child theme style
   
        */
   
       add_action( 'wp_enqueue_scripts', 'onepress_child_enqueue_styles', 15 );
   
       function onepress_child_enqueue_styles() {
   
           wp_enqueue_style( 'onepress-child-style', get_stylesheet_directory_uri() . '/style.css' );
   
       }
   
       /**
   
        * Hook to add custom section after about section
   
        *
   
        * @see wp-content/themes/onepress/template-frontpage.php
   
        */
   
       /*
   
       function add_my_custom_section(){
   
           ?>
   
           <section id="my_section" class="my_section section-padding onepage-section">
   
               <div class="container">
   
                   <div class="section-title-area">
   
                       <h5 class="section-subtitle"> My section subtitle</h5>
   
                       <h2 class="section-title"> My section title</h2>
   
                   </div>
   
                   <div class="row">
   
                       <!-- Your section content here, you can use bootstrap 4 elements :) -->
   
                       <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
   
                   </div>
   
               </div>
   
           </section>
   
           <?php
   
       }
   
       add_action( 'onepress_after_section_about', 'add_my_custom_section'  );
   
       */
       ```
   
 * When I re-upload it to my server, and try to open my site, I get the error:
 * Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mySite/
   domains/mySite.lt/public_html/wp-content/themes/onepress-child-master/functions.
   php on line 1
 * Which is really weird, because line 1 contains no code, just comments. If I delete
   the comments, I get different error:
 * Parse error: syntax error, unexpected ‘woocommerce_after_shop_loop_it’ (T_STRING)
   in /home/mySite/domains/mySite.lt/public_html/wp-content/themes/onepress-child-
   master/functions.php on line 1
 * It looks almost random. Weird thing is, if I add the woocommerce modifying function
   to the Onepress parent theme functions.php, it doesn’t throw any errors, and 
   works as expected. But adding the same code to child theme instead throws errors.
 * What is happening here?
 * EDIT: I tracked down that parser does not like this part from woocommerce_after_shop_loop_item_title_short_description()
   function:
 *     ```
       	?>
       	<div itemprop="description">
       		<?php echo apply_filters( 'woocommerce_short_description', $product->post->post_excerpt ) ?>
       	</div>
       	<?php
       ```
   
 * It’s almost as if closing and reopening php tag messes up something – but this
   works perfectly fine in the parent theme functions.php. I have no idea why.
    -  This topic was modified 6 years, 5 months ago by [laukejas](https://wordpress.org/support/users/laukejas/).

Viewing 1 replies (of 1 total)

 *  [longnguyen](https://wordpress.org/support/users/longnguyen/)
 * (@longnguyen)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-functions-to-onepress-child-theme-functions-php-causes-errors/#post-12256647)
 * Hi [@laukejas](https://wordpress.org/support/users/laukejas/)
 * Not sure the code has the problems when running with the child theme, but I’ve
   added your code to my child theme in a local site and no error like that happens.
   
   [https://cl.ly/f59ee4a9e678](https://cl.ly/f59ee4a9e678)

Viewing 1 replies (of 1 total)

The topic ‘Adding functions to Onepress child theme functions.php causes errors’
is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/onepress/2.3.18/screenshot.png)
 * OnePress
 * [Support Threads](https://wordpress.org/support/theme/onepress/)
 * [Active Topics](https://wordpress.org/support/theme/onepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/onepress/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/onepress/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [longnguyen](https://wordpress.org/support/users/longnguyen/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/adding-functions-to-onepress-child-theme-functions-php-causes-errors/#post-12256647)
 * Status: not resolved