get_header_image() returns null

While working on a theme in wordpress 3.4.2, I realised that wordpress function get_header_image() returns null in a ‘mu-plugins’ plugin even though in the theme’s functions.php file I’ve set a ‘default-image’ like this:

add_theme_support( 'custom-header', array(
    'default-image' => get_template_directory_uri() . '/subdir/default-header-image.jpg'
  )
);

In the theme template file header.php, I’ve called get_header_image(), and it returns the default image properly on the front-end.

It seems the ‘default-image’ defined in functions.php add_theme_support is not ‘saved’ into the database upon theme activation. And most probably because functions.php is loaded after mu-plugins, and therefore in the plugin it’s not possible to use get_header_image() to get the  ‘default-image’ defined in ‘add_theme_support’.

Well, now the question is whether wordpress should save the ‘default-image’ to database upon theme activation? Comments anyone?

Leave a Comment