Title: How to use Child Theme for PHP code?
Last modified: August 21, 2016

---

# How to use Child Theme for PHP code?

 *  [agusbagus](https://wordpress.org/support/users/agusbagus/)
 * (@agusbagus)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/)
 * Hi Support,
 * I have been googling anywhere and still can’t find a solution.
    I would like 
   to use a child theme for my WordPress and still not working. It’s not about css
   file but about PHP code. I have copied the file and folder exactly same to child
   theme and edit it but it doesn’t work. WP still uses setting from the original
   theme. The theme I use is estore from elegantthemes and unfortunately their support
   is very slow and not really helpful. There is a file that contains code to resize
   image to some sizes. The file is located at epanel/post_thumbnails_estore.php.
   I copied it to child theme and edited the size (1st line) from **193×130** to**
   193×200** as shown below.
 *     ```
       $et_theme_image_sizes = array(
       		'193x200'	=> 'et-entry-thumb',
       		'1400x501' 	=> 'et-featured-thumb',
       		'109x109' 	=> 'et-featured-small-thumb',
       		'162x112' 	=> 'et-scroller-thumb',
       		'298x130' 	=> 'et-single-product-thumb',
       		'298x226' 	=> 'et-single-product-thumb2',
       		'44x44' 	=> 'et-related-item-thumb',
       	);
       ```
   
 * What else I missed? pls advise.
    Thanks, Agus
 * Complete code of file post_thumbnails_estore.php:
 *     ```
       <?php
       	add_theme_support( 'post-thumbnails' );
   
       	global $et_theme_image_sizes;
   
       	$et_theme_image_sizes = array(
       		'193x200' 	=> 'et-entry-thumb',
       		'1400x501' 	=> 'et-featured-thumb',
       		'109x109' 	=> 'et-featured-small-thumb',
       		'162x112' 	=> 'et-scroller-thumb',
       		'298x130' 	=> 'et-single-product-thumb',
       		'298x226' 	=> 'et-single-product-thumb2',
       		'44x44' 	=> 'et-related-item-thumb',
       	);
   
       	$et_page_templates_image_sizes = array(
       		'184x184' 	=> 'et-blog-page-thumb',
       		'207x136' 	=> 'et-gallery-page-thumb',
       		'260x170' 	=> 'et-portfolio-medium-page-thumb',
       		'260x315' 	=> 'et-portfolio-medium-portrait-page-thumb',
       		'140x94' 	=> 'et-portfolio-small-page-thumb',
       		'140x170' 	=> 'et-portfolio-small-portrait-page-thumb',
       		'430x283' 	=> 'et-portfolio-large-page-thumb',
       		'430x860' 	=> 'et-portfolio-large-portrait-page-thumb',
       	);
   
       	$et_theme_image_sizes = array_merge( $et_theme_image_sizes, $et_page_templates_image_sizes );
   
       	$et_theme_image_sizes = apply_filters( 'et_theme_image_sizes', $et_theme_image_sizes );
       	$crop = apply_filters( 'et_post_thumbnails_crop', true );
   
       	if ( is_array( $et_theme_image_sizes ) ){
       		foreach ( $et_theme_image_sizes as $image_size_dimensions => $image_size_name ){
       			$dimensions = explode( 'x', $image_size_dimensions );
       			add_image_size( $image_size_name, $dimensions[0], $dimensions[1], $crop );
       		}
       	}
       ?>
       ```
   

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824596)
 * Consider switching to a theme [distributed on WordPress.org](http://wordpress.org/themes/),
   as we do not have access to commercial themes and therefore are unlikely to be
   able to resolve this.
 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824598)
 * See:
 * [http://codex.wordpress.org/Child_Themes#Using_functions.php](http://codex.wordpress.org/Child_Themes#Using_functions.php)
 *  Thread Starter [agusbagus](https://wordpress.org/support/users/agusbagus/)
 * (@agusbagus)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824600)
 * Hi Andrew Thanks, I understand about your condition and limitation to commercial
   themes. But what I need is basically to learn how child theme works.
    I read 
   from everywhere about child theme is just need to copy the PHP file and folder
   exactly the same hierarchy to child theme and edit it from there. But it doesn’t
   work in my case.
 * Thanks,
    Agus
 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824601)
 * No, that’s not how the functions.php file works in a child theme – see the link
   I posted above.
 *  Thread Starter [agusbagus](https://wordpress.org/support/users/agusbagus/)
 * (@agusbagus)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824603)
 * Hi Yogi,
 * I checked the code (posted above), it doesn’t contain function, does it?
    Sorry
   my PHP skill is not really good. Thanks for your advice.
 * Agus
 *  Thread Starter [agusbagus](https://wordpress.org/support/users/agusbagus/)
 * (@agusbagus)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824611)
 * I have function.php in child theme and contains one function there that works.
   But I copied above code to function.php it doesn’t work.
 * _[[bump ](http://codex.wordpress.org/Forum_Welcome#No_Bumping)moderated]_
 *  [Shaun Scovil](https://wordpress.org/support/users/sscovil/)
 * (@sscovil)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824618)
 * You copied the parent theme’s `functions.php` file into your child theme folder
   and are just editing it, yeah?
 * The problem is, a child theme’s `functions.php` file does not override that of
   the parent theme; they both get loaded. I am familiar with Elegant Themes (and
   their poor customer service), so I will take a look…
 *  [Shaun Scovil](https://wordpress.org/support/users/sscovil/)
 * (@sscovil)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824620)
 * Okay, first I would recommend starting with an empty `functions.php` file in 
   your child theme — or one that only contains functions you wrote.
 * Next, add this somewhere inside your PHP tags:
 *     ```
       function overwrite_et_image_size_06082013() {
           global $_wp_additional_image_sizes;
           $name = 'et-entry-thumb';
           $_wp_additional_image_sizes[$name] = array(
               'width'  => 193,
               'height' => 200,
               'crop'   => true
           );
       }
       add_action( 'after_theme_setup', 'overwrite_et_image_size_06082013', 99 );
       ```
   
 * That should overwrite the image size.
 *  Thread Starter [agusbagus](https://wordpress.org/support/users/agusbagus/)
 * (@agusbagus)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824633)
 * Hi Shoun,
    Thanks for helping. I have tried exactly as instructed but still not
   working. Still can’t find an image with size 193*200. I found at function.php
   parent theme this line code:
 * `require_once($template_dir . '/epanel/post_thumbnails_estore.php');`
 * Is this something I should add to function child theme?
    I tried but it didn’t
   work or I added it wrong way?
 * Full code of function.php parent theme can be found here:
    [http://pastebin.com/vBPbBPYz](http://pastebin.com/vBPbBPYz)
 *  [Shaun Scovil](https://wordpress.org/support/users/sscovil/)
 * (@sscovil)
 * [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824662)
 * Sorry, I messed up the action hook…it’s supposed to be `after_setup_theme`, not`
   after_theme_setup`.
 * So change that last line to:
 *     ```
       add_action( 'after_setup_theme', 'overwrite_et_image_size_06082013' );
       ```
   
 * You’ll notice I removed the ’99’ from the end there. I read up on the order of
   things, and apparently the child theme `functions.php` file loads first, then
   the parent theme’s `functions.php`, then the `after_setup_theme` hook fires. 
   So no need to give this function a different priority, because it will run after
   the parent theme is loaded — which is what we want.
 * Also, if you already have your images uploaded you’ll want to install and run
   the [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/)
   plugin!

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

The topic ‘How to use Child Theme for PHP code?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 4 participants
 * Last reply from: [Shaun Scovil](https://wordpress.org/support/users/sscovil/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/how-to-use-child-theme-for-php-code/#post-3824662)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
