Support » Fixing WordPress » Override parent files from childtheme

  • Greetings everyone,

    a quite basic question here. For some reason I am searching everywhere for a solution and I can not find anything. Let me start explaining what I need.

    Got a parent theme called ‘traveler’. I have also created a child theme. Some files copied from the parent to the child theme after the customizations work just fine, the website changed and everything runs smoothly. the problem appers when I am trying to override some specific files (its about specific folders then files). For example the path /inc/admin/class/… contain some files mostly handling the requests from forms. Copying those files in the child theme and creating the exact paths does not seem to work. Any changes to child theme does not have any affect to the website.

    I am reading many things, some people say that this stuff that I am trying to do CAN NOT be done, some other say that I have to put some lines on every file that I have to change, bla bla bla…

    I just need some explanations here, why this does not work and how can i solve this problem. I am not seeking for a solution that will crash when the update comes, I am seeking for knowledge.

    Lastly, I have tried to copy the function that I have changed in the parent theme, into the functions.php file in the child theme and a white page appers. Dunno what is going wrong.

    I hope this description helps and I hope that we can solve this problem one and for all.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steve Stern (sterndata)


    Forum Moderator & Support Team Rep

    It depends on how the parent theme includes files — do they “hard code” in paths, use get_template_directory() or get_stylesheet_directory(), etc. You may have to copy over all the intermediate files. Also, you can’t have a function with the same name as one in the parent unless the parent creates that function as a “pluggable” function. Not all themes are built to be easily child themed. This is unfortunate.

    Thread Starter BillyTziv


    Great. Let me try help a bit. (I hope…)

    I got a file named class.tour.php where there is actually a check at the beginning of the file if the class exists and if not this file declares a class with all of its function. At the end it creates an instance.

        if ( !class_exists( 'STTour' ) ) {
            class STTour extends TravelerObject
         static    $_inst;
                protected $post_type = "st_tours";
                protected $orderby;
                 * @var string
                 * @since 1.1.7
                protected $template_folder = 'tours';
                function __construct( $tours_id = false )
                    $this->orderby = [
                        'new'        => [ .....

    And here is the end of the file:

                static function get_price_type($id = null){
                        $id = get_the_ID();
                    $price_type = get_post_meta($id, 'tour_price_by', true);
    		            $price_type = 'person';
    	            return $price_type;
            st()->tour = STTour::get_instance();
    Thread Starter BillyTziv


    Let me post a block of code I found. This code is in the class.traveler.php file. My theme name is traveler. I believe this loads all the files.


    Does this help?

    You really should be asking at the theme’s support forum.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Override parent files from childtheme’ is closed to new replies.