Site logo

Archived topic

cant output logo on desktop

4 replies · Started by Viktor on October 28, 2021

Viewing posts 1–5 of 5

Hello dear support!

i cant output standart logo on desktop
see my way:

/**custom_logo**/

//add this code in function.php

add_theme_support( 'custom-logo' );

function themename_custom_logo_setup() {
$defaults = array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
'unlink-homepage-logo' => true,
);

add_theme_support( 'custom-logo', $defaults );
}

add_action( 'after_setup_theme', 'themename_custom_logo_setup' );

// add this code in hook (output of current theme logo)

<?php
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );

if ( has_custom_logo() ) {
echo '' . get_bloginfo( 'name' ) . '';
}
?>

see description of my way and pls help me output logo on desktop ...

veiw

Do you need wp-admin access ?

Hi Viktor,

There shouldn't be any need for any custom PHP snippets if you only want to add a logo on the Theme's header.

You can simply add the logo image file on your site's media library and assign it as the logo on Appearance > Customize > Site Identity.

But to clarify: Were you trying to move the logo to a specific part of the site?

I've checked your page and it doesn't seem to be using a default theme header and this particular part of the site seemed hooked or baked in on a child theme - https://share.getcloudapp.com/qGuRlrOk

Now if you want to use the logo you've uploaded on the site library programmatically, you can fetch its value using esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ) for its href value and esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ) for the logo image title.

There's no need for add_theme_support for logo because it's already done on the functions.php of the theme as shown here -
https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/functions.php#L45-L53

This archived topic is closed to new replies.