Title: Overwrite a specific function in child theme
Last modified: August 24, 2016

---

# Overwrite a specific function in child theme

 *  [ste_yeu](https://wordpress.org/support/users/ste_yeu/)
 * (@ste_yeu)
 * [11 years ago](https://wordpress.org/support/topic/overwrite-a-specific-function-in-child-theme/)
 * Hello,
 * what’s the best way to overwrite a specific function in a php file of a parent
   theme? I mean a specific php file, **that isn’t the _functions.php_ file**.
 * In my case, I need to change the default image that appears in slider if there
   isn’t a featured image. This is the code in _my\_actived\_theme/includes/theme-
   plugins.php_:
 *     ```
       // If there is no image, use the default image (available filter: mag_post_image_none).
   
       		if (isset($attachment[0])) {
       			$post_image_uri = $attachment[0];
       		} elseif ( 'slider' == $size ) {
       			$post_image_uri = apply_filters( 'mag_slider_image_none', get_template_directory_uri() . '/images/no-image.jpg' );
       		} else {
       			$post_image_uri = apply_filters( 'mag_post_image_none', get_template_directory_uri() . '/images/no-image-small.jpg' );
       		}
   
       		// If no image, return now
       		if ( $post_image_uri == apply_filters( 'mag_slider_image_none', get_template_directory_uri() . '/images/no-image.jpg' ) || apply_filters( 'mag_post_image_none', get_template_directory_uri() . '/images/no-image-small.jpg' ) )
       			return $post_image_uri;
   
       		// If MU/MS install, we need to dig a little deeper and link through the blogs.dir.
       		if ('IS_MU') {
       			$imageParts = explode('/files/', $post_image_uri);
       			if (isset($imageParts[1])) {
       				$post_image_uri = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
       			}
       		}
   
       		return $post_image_uri;
       	}
       endif;
       ```
   
 * So how can I edit this code? (in my example, I need to change the image url).
 * I hope my English is clear. :/
 * Thanks in advance! 🙂

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

 *  Thread Starter [ste_yeu](https://wordpress.org/support/users/ste_yeu/)
 * (@ste_yeu)
 * [11 years ago](https://wordpress.org/support/topic/overwrite-a-specific-function-in-child-theme/#post-6124610)
 * Up.
 * Any suggestions, please?
 * Could I use a copy of file _**theme-plugins.php**_ and place it in a folder called
   _includes_ in the child theme? So I had the same path and file:
 * theme_child/includes/theme-plugins.php
 *  Thread Starter [ste_yeu](https://wordpress.org/support/users/ste_yeu/)
 * (@ste_yeu)
 * [11 years ago](https://wordpress.org/support/topic/overwrite-a-specific-function-in-child-theme/#post-6124660)
 * The above solution does not work.

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

The topic ‘Overwrite a specific function in child theme’ is closed to new replies.

## Tags

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

 * 2 replies
 * 1 participant
 * Last reply from: [ste_yeu](https://wordpress.org/support/users/ste_yeu/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/overwrite-a-specific-function-in-child-theme/#post-6124660)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
