Site logo

Archived topic

Child theme being overwritten by parent theme

5 replies · Started by Sue on March 7, 2021

Viewing posts 1–6 of 6

I recently redesigned a website that had initially been designed using a theme that was no longer being updated or supported. It was a huge job, and part of it involved keeping a bunch of formatting intact on a certain subset of pages. I created a child theme so I could tweak some of the files without them being overwritten when GP updates. However, when GP updated a few days ago, it messed up the formatting, so obviously I have something in the parent theme that needs to be in the child theme. I reinstalled the prior version of GP from my backup, and then it looked fine again.

Is there a simple way to figure out which files in the parent theme are being used on this subset of pages so I can move them into the child theme, either through view source, inspect, etc.?

Hi there,

It's hard to tell without knowing which especifically is being affected.

Can you explain a bit more which are being overwritten?

It'd be great to have a clone of your site with the newer version to have a point of comparison between the 2 versions.

The pages which are affected are the book pages, like the one I linked to in the private info box.
There's a file called page-book.php in the child theme which controls the format (the bookstore icons, etc.).
When I view source on that page, I see this in the body tag:
<body data-rsssl=1 class="page-template page-template-page-book page-template-page-book-php page page-id-15196 page-child parent-pageid-10 logged-in admin-bar no-customize-support wp-embed-responsive post-image-aligned-center secondary-nav-float-right secondary-nav-aligned-right sticky-menu-fade no-sidebar nav-below-header separate-containers header-aligned-left dropdown-hover" itemtype="https://schema.org/WebPage" itemscope>
page-book.php is only in the child theme; if I comment it out, everything disappears except the one paragraph of description that is visible under the bookstore icons.
The site is SO huge that it's not really feasible to clone it, unfortunately!

Using a file like that in your child theme should work just fine, even after you update the theme.

What exactly went wrong after the update?

I finally figured it out by updating GP, then going to my backup and uploading files one by one, and then refreshing the page until it looked the way it should. It turns out it's the assets/css folder in GP. I have that folder in my child theme but for some reason the page is drawing on the assets/css folder in the parent theme instead.

Child themes can't overwrite files in sub-folders - they will only overwrite the files in the root folder of the parent theme.

The assets themselves cannot be overwritten via the child theme - you need to add your own assets to the child theme and overwrite the existing CSS with your own CSS.

Hope this helps!

This archived topic is closed to new replies.