Archived topic
Child Theme for V3
13 replies · Started by ETO on November 9, 2020
Hello,
Is the child theme here compatible with latest version of Generatepress?
I had my developer make some customizations for my website and he said the child theme didn't work properly, that was why he made the changes in parent theme.
According to what I have been told, it is the same problem here: https://generatepress.com/forums/topic/including-parent-theme-file-in-child-theme/
He says he cannot include parent theme's folders/files in child theme.
Hi there,
Is the child theme here compatible with latest version of Generatepress?
Yes - that child theme simply grabs the files from the parent theme so it will be compatible with all versions of the theme.
What file is he trying to modify?
I've explained the issue for that post here:
https://generatepress.com/forums/topic/including-parent-theme-file-in-child-theme/#post-1508732
He modified some files in "inc" and "assets" folders.
So as mentioned in the previous post:
By default, WordPress only allows child theme overwrites on the first level of files – so the files directly under the theme folder.
And this is not a theme thing.
What changes is he trying to make?
Hello again, Leo!
You can find all the changes he made in the file who link I sent you as private information.
I would be grateful if you can find an easy way to implement these changes so that I don't miss the updates of the theme.
That's not something the theme support can help with - you will need to contact your previous developer or use a service like this:
https://generatepress.com/forums/topic/can-i-turn-my-gp-theme-into-a-child-theme/#post-592017
You had told me that most of the changes could be done with hooks. That is why I sent you my customization codes and ask you if these changes can be done with hooks or not.
I'm not sure what some of the code is supposed to do.
To give you a few examples:
I see a lot of CSS that should all be added using one of these methods:
Adding CSS: https://docs.generatepress.com/article/adding-css/
If it says "at the bottom of function.php", then it should be added using one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/
And if it says "Before wp_head in header.php", then that should be added using the wp_head hook:
https://docs.generatepress.com/article/wp-head/
https://docs.generatepress.com/article/hooks-element-overview/
I would recommend getting in contact with your developer and ask him to do things the proper way.
This is outside of our forum support scope.
Most of the thins can be done by Hooks and the Snippets plugin. However, adding the necessary code to the 33rd line in inc/structure/archive.php is not possible by using Snippets plugin.
What is that code for?
Hi,
every code in inc/structure/archive.php are added by using hooks. If it's added by hook so it can be removed too using theremove_action function
https://developer.wordpress.org/reference/functions/remove_action/
so it's possible for your developer just to remove a hooked function and replace it with another function using only child-theme or the code snippets plugin
What is that code for?
Hi Leo! You can see what it is for by looking at the file I sent you.
Hi,
every code in inc/structure/archive.php are added by using hooks. If it’s added by hook so it can be removed too using theremove_action function
https://developer.wordpress.org/reference/functions/remove_action/
so it’s possible for your developer just to remove a hooked function and replace it with another function using only child-theme or the code snippets plugin
How is it possible to add code in inc/structure/archive.php by using hooks?
Can you provide to us what kind of code you want to add and what line in inc/structure/archive.php you want to change?
Here is the archive you want to change if you need to remember where exactly you want to modify -
https://github.com/tomusborne/generatepress/blob/master/inc/structure/archives.php
We need to understand better what you want - it's very easy you to remove a hook in favor of a new hook but breaks existing functionality.
Theses hooks are the most safe for you to hook into:
https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/archives.php#L31
https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/archives.php#L46
https://github.com/tomusborne/generatepress/blob/3.0.2/inc/structure/archives.php#L116
Here a code sample if I want to add a description after archive title (line 46) - this code should be added in your child-theme's functions.php
add_action( 'generate_after_archive_title', 'generatepress_child_custom_archive_description' );
function generatepress_child_custom_archive_description() {
echo '<p>here goes a custom archive description</p>';
}
Here a more detailed documentation about hooks
Hi, Thiago!
You can see all the customizations we made to the theme here.