Title: Default Theme Settings
Last modified: August 20, 2016

---

# Default Theme Settings

 *  Resolved [jeff.cave](https://wordpress.org/support/users/jeffcave/)
 * (@jeffcave)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/default-theme-settings/)
 * I’m trying to create a child theme, all the child theme is supposed to do is 
   to preset some of the theme options.
 * I have tried two different methods, neither worked…
 * Method 1
 *     ```
       add_action( 'after_switch theme', 'psTheme_setup1' );
   
       function psTheme_setup2(){
       	set_theme_mod('background_image', 'http://localhost/sites/green/files/2013/01/Abstract_Green_Background_with_Floral_Elements.jpg');
       }
   
       function psTheme_setup1(){
       	global $wpdb;
       	$themeConfig = 'a:8:{s:16:"background_image";s:102:"http://localhost/sites/green/files/2013/01/Abstract_Green_Background_with_Floral_Elements.jpg";s:17:"background_repeat";s:9:"no-repeat";s:21:"background_position_x";s:6:"center";s:21:"background_attachment";s:6:"scroll";s:16:"background_color";s:6:"69e01f";s:12:"header_image";s:75:"http://localhost/sites/green/files/2013/01/cropped-cow-header1.jpg";s:17:"header_image_data";O:8:"stdClass":5:{s:13:"attachment_id";i:8;s:3:"url";s:75:"http://localhost/sites/green/files/2013/01/cropped-cow-header1.jpg";s:13:"thumbnail_url";s:75:"http://localhost/sites/green/files/2013/01/cropped-cow-header1.jpg";s:6:"height";i:250;s:5:"width";i:960;}s:16:"header_textcolor";s:6:"0e5059";}';
       	$wpdb->insert($wpdb->options, [
       			'option_name'=>'theme_mods_green2012',
       			'option_value'=>$themeConfig
       		],['%s','%s']);
       	$wpdb->update(
       		$wpdb->options,
       		['option_value'=>$themeConfig],
       		['option_name'=>'theme_mods_green2012'],
       		['%s'],['%s']
       		);
   
       }
       ```
   
 * That’s it for the entire theme. The parent is “Twenty Twelve”. After switching
   themes, there has been no modification to the database. The big string I am trying
   to update the database with is a copy/paste from mysql.

Viewing 1 replies (of 1 total)

 *  Thread Starter [jeff.cave](https://wordpress.org/support/users/jeffcave/)
 * (@jeffcave)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/default-theme-settings/#post-3406741)
 * Stupid mistakes…
 * `add_action( 'after_switch theme', 'psTheme_setup1' );`
 * should be
 *     ```
       add_action( 'after_switch_theme', 'psTheme_setup1' );
         // problem is here-----^
       ```
   
 * Hopefully someone finds the code useful so this post isn’t a total waste…

Viewing 1 replies (of 1 total)

The topic ‘Default Theme Settings’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [jeff.cave](https://wordpress.org/support/users/jeffcave/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/default-theme-settings/#post-3406741)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
