1

I'm trying to use my custom logo, uploaded from Appearance > Header. But none of the parameters I have set in my_custom_logo_setup are working.

In functions.php

//Add custom logo function my_custom_logo_setup() { $defaults = array( 'height' => 100, //not working! 'width' => 100, //not working! 'flex-height' => true, //not working! 'flex-width' => true, //not working! 'header-text' => array( 'site-title', 'site-description' ), //not working! 'unlink-homepage-logo' => true, //not working! ); add_theme_support( 'custom-logo', $defaults ); } add_action( 'after_setup_theme', 'my_custom_logo_setup' ); 

In header.php:

<header id="masthead" class="site-header site-title site-description"> <div class="site-branding"> <?php if ( function_exists( 'my_custom_logo_setup' ) ) { the_custom_logo(); } ?> <h1 class="site-title">Titulo</a></h1> <p class="site-description">Description</a></p> </div> <!-- .site-branding --> <!-- <nav id="site-navigation" class="main-navigation"> </nav> --> <!-- #site-navigation --> </header><!-- #masthead --> 
5
  • in your theme you are testing for the existence of my_custom_logo_setup rather than the_custom_logo as is usual. Why?
    – cjbj
    CommentedJul 31, 2024 at 7:58
  • well, I'm testing if my custom function (my_custom_logo_setup) exists, since I created it; I thought this would be the right way. Anyway, even if I change it to function_exists(the_custom_logo), the result is identical.CommentedJul 31, 2024 at 8:04
  • Otherwise I don't see anything unusual about your code. It might be some other code (plugin) interfering with it. Have you tried a later priority on after_setup_theme?
    – cjbj
    CommentedJul 31, 2024 at 9:57
  • Could you explain me what means "later priority on after_setup_theme" ?CommentedJul 31, 2024 at 12:25
  • That would be add_action( 'after_setup_theme', 'my_custom_logo_setup', 999 ); The last number is the priority. This means this action will be added after other actions. So if there is a plugin that also ads a custom logo, it will be overwritten by your code. But there could also be filters that override the logo.
    – cjbj
    CommentedJul 31, 2024 at 14:52

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.