WordPress 4.5 - built in theme logo support

add_theme_support( 'site-logo', size );
add_theme_support( 'custom-logo' );

details: https://codex.wordpress.org/Theme_Logo

Love when they add stuff like this, it means we can remove our custom controllers and rely on core WP features/documentation better.

1 Like

this might help -> http://www.wpbeginner.com/news/whats-coming-in-wordpress-4-5-features-and-screenshots/

It seems there’s some confusion with the docs and various blog posts about the topic.

Codex says it is: add_theme_support( 'custom-logo' );


Other places say: add_theme_support( 'site-logo' );

I think the one that works is custom-logo, so use that.

and to show a default logo:

   if(empty($html)){ $html = '<img src="my default logo here">'; }
   return $html;

nice share

Hi, I used this code to try to set a DEFAULT logo in my theme but it’s not working.
Is there a problem with the syntax maybe - mix of " and ’ in the code.
Any ideas?

   if(empty($html)) { 
	 $html = '<img src = get_template_uri() . "/img/logo.jpg" >'; 
   return $html;

try this

$logo_id = get_theme_mod( 'custom_logo' );
		$logo = wp_get_attachment_image_src( $logo_id , 'full' );
		$logo_path = get_template_directory_uri() . "/img/logo.png";

    							if( has_custom_logo() ) :
    								echo "<a href='". esc_url( home_url( '/' ) ) ."'>";
    								echo "<img src='". esc_url( $logo[0] ) ."' /></a>";
    							else :
    								echo "<a href='". esc_url( home_url( '/' ) ) ."'>";
    								echo "<img src='". esc_url( $logo_path ) ."' /></a>";

Hi mabuc,
Thanks for coming back.
I tried your code and it is progress - it does make the logo appear on the top left of the site - before any other content.
Unfortunately it doesn’t sit where the logo is.
It’s also messing up the backend slightly.

Seem to be close to a solution!

One hint is a warning I see:
Cannot modify header information - headers already sent by (output started at …/htdocs/wp-content/themes/mynewtheme/inc/setup.php:124)

I used it on all of my themes and I have no problem with it. I think you should check your other codes that might cause your warning for header information.

OK, I will have a look.
Thanks for your help mabuc!