• Good day.

    I’m developing a new block theme and want to have a default logo to show it in the Site Logo block without uploading it from the Media Library. This code solves my problem well:

    function get_custom_logo_callback( $html ) {
    
        if ( !has_custom_logo() ) {
            $aria_current = is_front_page() && ! is_paged() ? ' aria-current="page"' : '';
    
    		$image =  sprintf('<img src="%1$s" />', get_theme_file_uri( '/assets/images/logo-simple.svg'));
    
            $html = sprintf(
                '<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>',
                esc_url( home_url( '/' ) ),
                $aria_current,
                $image
            );
        }
    
    	return $html;
    }
    
    add_filter( 'get_custom_logo', 'get_custom_logo_callback' );

    So, when I run my site, I can see my internal logo image (because Site Logo block calls standard get_custom_logo() function) and I’m happy.

    But I do not see the logo during the editing page process – Site logo block thinks the logo does not exist. I guess it uses another method to get the logo (not get_custom_logo() function).

    Is there way to show my logo by default? May be another WP hook? I’d like to have my page look similar in edit and run modes.

    Thank you in advance,
    Serge`

    • This topic was modified 2 years, 7 months ago by Serge Gusev.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Default logo for the Site logo block’ is closed to new replies.