WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a theme author and the theme I made is used in a multisite environment. I have added the custom_background feature to this theme, with a default image and everything works as expected : the user can change the image and see the result live is the Theme Customizer before putting it online.

Here is the custom_background declaration:

add_action('after_setup_theme', 'user83643_theme_features');
function user83643_theme_features(){
    add_theme_support( 'custom-background' , array(
        'default-color' => '1878A0',
        'default-image' => get_template_directory_uri() . '/img/default.jpg',
        'wp-head-callback' => '__return_false',

However, when a fresh new site is created in the network, the default image does not appear in the frontend. I can see it in the backend in the theme customizer, but I have to save it once to activate it on the frontend : get_theme_mod('background_image') returns false before I save it once.

Any idea how to save the default image (and color) in the database upon the first theme activation ?

share|improve this question
up vote 0 down vote accepted

I assume you mean "get_theme_mod('background_image') returns false" before I "save it once to activate it"

If that is the case, get_theme_mod accepts a default parameter. Check the Codex:

$name (string) (required) Theme modification name.

    Default: None 

$default (boolean|string) (optional)

    Default: false

Pass your default image as the second parameter to that function and you should be set.

share|improve this answer
This is exactly what I was looking for ! Thanks ! – Fabien Quatravaux Mar 8 '13 at 15:05
I have edited my question following your recommendations to make it clearer. – Fabien Quatravaux Mar 8 '13 at 15:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.