Archived topic
Keep child theme(s) customizer(s) seperate from parent
7 replies · Started by rikdol on May 11, 2022
i've created 2 child themes on a wordpress site powered by generatepress.
The changes i make inside the customizer while a child theme is activated, are still used by the parent and second child theme.
How do i keep these seperate?
the functions.php file in the 2 child themes looks like this:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
To clarify, i made the first child theme to copy the layout of the current website.
I then made a second child theme with different color/background options. But i think, because i'm loading parent styles, every change i make is copied to the parent and all child themes now.
How can i make a copy/child theme of parent, and then make changes that are only saved to the current active child theme
Do i need to copy the \inc folder to the child theme as well to get have the customizer seperate from the parent theme?
I changed the functions.php file since it looked like i wasnt loading child_theme_styles. ( at least that's what i found online )
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'child_theme_styles' );
function child_theme_styles() {
wp_enqueue_style( 'child-theme-css', get_stylesheet_directory_uri() .'/style.css' , array('parent-style'));
}
?>
But still, changes i make to customizer, inside an active child theme, are also changed inside the parent theme..
Hi there,
Customizer settings are only saved against the Parent theme.
The options are:
1. Export your settings from Appearance > GeneratePress and then import them to your other sites.
2. Programatically set the customizer defaults using a child theme - see Toms explanation here:
https://generatepress.com/forums/topic/syncing-settings/#post-985940
And see below for link to latest theme defaults.php
https://github.com/tomusborne/generatepress/blob/release/3.1.4/inc/defaults.php
Exporting and importing will only work on different sites then, not the child theme. These are not seperate sites. just seperate layouts i made using the customizer.
importing the exported settings will just overwrite the parent customizer.
So does that mean that what i want can't be done. unless i create a whole new installation of wordpress in a subfolder? I thought customizer settings were saved to their own child theme database setting
Or should I remove those php lines and then import the settings from the parent?
The active theme throws me off. suggesting that i'm customizing the active theme instead of the parent
WordPress by default outputs the title of the current theme in the customizer.
But apart from the Site Identity and Copy Right information ( which are both content ) - no Customizer settings are saved to the Child Theme tables in the database. Its not how WP or GP works.
The only way to do what you require is to use the Child Theme to load the customizer defaults. As per point 2 above:
https://generatepress.com/forums/topic/keep-child-themes-customizers-seperate-from-parent/#post-2216068