From my research there are only two questions I've found around this topic on this site:

outside of the site I did find:

but when I try:

function default_icon() {
  global $wp_customize;
  $wp_customize->get_setting('site_icon',array (
    'default' => home_url() . 'img/test.png'

I've also tried add_setting with:

function default_icon() {
  global $wp_customize;
  $wp_customize->add_setting('site_icon', array(
    'default' => home_url() . 'img/test.png'

but that doesn't work either. It will not show the default icon in the drag and drop area and renders "No Image selected":

enter image description here

In my functions.php how can I code my theme to render the default icon presently being used in the drag and drop area?

After further testing I can set the default when I code:


and I can see it in a dump of $wp_customize but as far as rendering it will not.

  • Could you post your code with add_setting? It should work fine. – Krzysiek Dróżdż Jan 9 '19 at 17:56
  • It's the same as above but with just add_setting. – DᴀʀᴛʜVᴀᴅᴇʀ Jan 9 '19 at 18:07
  • Hmm, do you have to set default value for that setting? Would displaying your custom icon when no icon is set be enough? – Krzysiek Dróżdż Jan 9 '19 at 20:12

You can see the customizer API to set default icon. This should do the trick, I guess:

function mytheme_customize_register( $wp_customize ) {

    $wp_customize->add_setting( 'site_icon' , array(
        'default'     => get_bloginfo('template_url') . '/images/logo.png',
    ) );

add_action( 'customize_register', 'mytheme_customize_register' );
  • Thanks for trying but I've already tried that approach, edited question to show code, also note that you need to call global $wp_customize or you'll error out. – DᴀʀᴛʜVᴀᴅᴇʀ Jan 9 '19 at 18:43
  • @DᴀʀᴛʜVᴀᴅᴇʀ You're right. It works in that sense it really sets the default value for that setting - you can see it var_dumping $wp_customize object, but it doesn't change the value of control... – Krzysiek Dróżdż Jan 9 '19 at 20:32
  • Ya but that still doesn't solve the question – DᴀʀᴛʜVᴀᴅᴇʀ Jan 9 '19 at 23:16
  • 1
    @DᴀʀᴛʜVᴀᴅᴇʀ I know - I’ll leave it here so I can get back to it tomorrow – Krzysiek Dróżdż Jan 9 '19 at 23:18

The site icon is not a theme setting, so the the theme should not be supplying a default.

edit: source: Wordpress Theme Handbook - Customizer Objects

Note: themes generally should not modify core sections and panels with the get methods, since themes should not modify core, theme-agnostic functionality. Plugins are encouraged to use these functions where necessary. Themes should not “reorganize” customizer sections that aren’t added by the theme.

  • Isn't it annoying when you get down voted with no explanation? True, your answer wasn't super helpful and could have been expanded upon – notably with references supporting your argument. The wordpress team have included a site icon upload option by default and have expressly asked theme authors not to modify default customizer settings so you're on point. Bumping your answer +1 for adhering to Wordpress theme guidelines. Going to edit your answer to include a relevant passage from the WP Theme Handbook. – dj.cowan Mar 7 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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