Archived topic
cant output logo on desktop
4 replies · Started by Viktor on October 28, 2021
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 '';
}
?>
see description of my way and pls help me output logo on desktop ...

Hi there,
Is there a reason why you are using a custom snippet/solution instead o using the customizer option?
https://docs.generatepress.com/article/adding-header-logo/
Can you link us to the page in question?
Thanks.
Hi Leo!
I use you way with current logo
And as you can see i use way with current logo from wordpress oficial website ( see part with Displaying the custom logo in your theme)
https://developer.wordpress.org/themes/functionality/custom-logo/
See my website with this problem: https://мирстрой.москва/
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