简体   繁体   中英

WordPress - Separate Theme Option Selections for Child Themes

I'm trying to create a website that is running two child themes of Duena ( https://wordpress.org/themes/duena ). The problem is that I am trying to set the colour scheme options for these themes to different values.

However, an issue arises because they both seem to share the same space on the database so when I modify the option of one, it affects the other. I've tried tinkering with the optionsframework_option_name() function in options.php; I copied it to both of the child themes and separately updated the $themename variable - this had no affect.

if(!function_exists('optionsframework_option_name')) {
    function optionsframework_option_name() {
        // This gets the theme name from the stylesheet (lowercase and without spaces)
        $themename = 'duena';

        $optionsframework_settings = get_option('optionsframework');
        $optionsframework_settings['id'] = $themename;
        update_option('optionsframework', $optionsframework_settings);

    }
}

I would assume the options.php files of the child themes are not overriding the file in the parent theme which caused my attempted solution to fail. I could be wrong entirely, of course, and if anybody has any ideas/thoughts on how I could achieve what I am trying to do, they are very welcome.

Why do you need two child themes sharing same code? Since, you can only use one child theme at a time, it doesn`t technically make sense. Just delete one and try setting the options again.

Although I have not managed to separate the options from each other in the database I have implemented a simple solution to my specific problem...

I simply copied the theme and renamed one of them before installing them both. The only downside to this is when it comes to receiving theme updates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM