Почему не отображается header logo?
создал пустышку темы на underscores.me.Сразу же после активации темы попробовал добавить лого в хедер через админпанель - в результате лого нет, в html пусто. код из пустышки
<div class="site-branding"> <?php the_custom_logo(); if ( is_front_page() && is_home() ) : ?> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <?php else : ?> <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> <?php endif; $itmentor_description = get_bloginfo( 'description', 'display' ); if ( $itmentor_description || is_customize_preview() ) : ?> <p class="site-description"><?php echo $itmentor_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p> <?php endif; ?> </div><!-- .site-branding --> |
<div class="site-branding"> <?php the_custom_logo(); if ( is_front_page() && is_home() ) : ?> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <?php else : ?> <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> <?php endif; $itmentor_description = get_bloginfo( 'description', 'display' ); if ( $itmentor_description || is_customize_preview() ) : ?> <p class="site-description"><?php echo $itmentor_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p> <?php endif; ?> </div><!-- .site-branding -->
все вроде инициализировано в functions.php
function itmentor_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on itmentor, use a find and replace * to change 'itmentor' to the name of your theme in all the template files. */ load_theme_textdomain( 'itmentor', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'menu-1' => esc_html__( 'Primary', 'itmentor' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'itmentor_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', array( 'height' => 400, 'width' => 400, ) ); } add_action( 'after_setup_theme', 'itmentor_setup' ); |
function itmentor_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on itmentor, use a find and replace * to change 'itmentor' to the name of your theme in all the template files. */ load_theme_textdomain( 'itmentor', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'menu-1' => esc_html__( 'Primary', 'itmentor' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'itmentor_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', array( 'height' => 400, 'width' => 400, ) ); } add_action( 'after_setup_theme', 'itmentor_setup' );
При этом фоновый рисунок, цвет текста хедера через кастомайзер меняется.
Очистка кеша не помогла.
Дополнительно:
В консоли браузера что пишет? Путь до изображения верный?
http://localhost/wordpress/wp-content/uploads/2023/09/cropped-cropped-cropped-headerLogo.jpg |
http://localhost/wordpress/wp-content/uploads/2023/09/cropped-cropped-cropped-headerLogo.jpg
. Я вордпрессом только начал интересоваться, поэтому ошибка может быть какая угодно. Но ведь а)фоновое изображение работает б)заготовка создана не мной. Функция показа лого базовая вроде, напортачить невозможно.
И ни в коем случае не нужно пытаться сделать "свою тему" пока не будет достаточно опыта в работе с ВП.
Поддерживаю 3 руками!
Поддерживаю 3 руками!
Мопед не мой, но я категорически согласен, поэтому эта ссылка у меня в закладках.
Методом проб и ошибок заработало. Скорее всего где-то не сохранил код в редакторе. Перед задаванием вопросов нужно делать перерыв в обучении чтобы не флудить.
Опишите проблему, и специалист поможет с настройкой, исправлением ошибки или доработкой сайта. Подберём понятный план работ без лишней переписки.
Пока нет других ответов. Будьте первым, кто поможет автору.
Ответить на вопрос
