the_custom_logo() 显示一个链接到主页的自定义徽标图像,因此您无需回显它,只需将其包装在其中a 标记或将其用作src 对于图像。
如果要使用默认输出,则只需在主题文件中使用即可。如果未设置自定义徽标,则该函数将生成一个空字符串,即不显示任何内容。
对于自定义输出,首先使用get_theme_mod( \'custom_logo\' ) 然后使用wp_get_attachment_image(). 或徽标图像urlwp_get_attachment_url() 或wp_get_attachment_image_src.
回退示例,修改自howget_custom_logo() 作品
$custom_logo_id = get_theme_mod( \'custom_logo\' );
if ( $custom_logo_id ) {
  $custom_logo_attr = array(
    \'class\' => \'custom-logo\',
  );
  printf(
    \'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>\',
    esc_url( home_url( \'/\' ) ),
    wp_get_attachment_image( $custom_logo_id, \'full\', false, $custom_logo_attr );
  );
} else {
  $custom_logo_attr = array(
    \'class\' => \'fallback-logo\',
  );
  printf(
    \'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>\',
    esc_url( home_url( \'/\' ) ),
    get_template_directory_uri() . \'/assets/images/logo.png\'
  );
}