#php #wordpress
Вопрос:
Ищу помощь в том, чтобы моя тема wordpress отображала изображение заголовка на всех страницах, а не только на домашней странице, как это происходит в настоящее время. Все страницы используют php-команду get_header и header.php содержит следующий код:
lt;?php /** * The header for our theme * * This is the template that displays all of the lt;headgt; section and everything up until lt;div id="content"gt; * * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials * * @package Superb_Landingpage */ ?gt; lt;!doctype htmlgt; lt;html lt;?php language_attributes(); ?gt;gt; lt;headgt; lt;meta charset="lt;?php bloginfo( 'charset' ); ?gt;"gt; lt;meta name="viewport" content="width=device-width, initial-scale=1"gt; lt;link rel="profile" href="http://gmpg.org/xfn/11"gt; lt;?php wp_head(); ?gt; lt;/headgt; lt;body lt;?php body_class(); ?gt;gt; lt;?php wp_body_open(); ?gt; lt;div class="navigation-wrapper"gt; lt;div class="site grid-container"gt; lt;header id="masthead" class="site-header grid-x grid-padding-x"gt; lt;div class="site-branding large-4 medium-10 small-9 cell"gt; lt;?php the_custom_logo(); if ( is_front_page() amp;amp; is_home() amp;amp; is_page() ) : ?gt; lt;div class="logo-container"gt; lt;h1 class="site-title"gt;lt;a href="lt;?php echo esc_url( home_url( '/' ) ); ?gt;" rel="home"gt;lt;?php bloginfo( 'name' ); ?gt;lt;/agt;lt;/h1gt; lt;?php else : ?gt; lt;div class="logo-container"gt; lt;h2 class="site-title"gt;lt;a href="lt;?php echo esc_url( home_url( '/' ) ); ?gt;" rel="home"gt;lt;?php bloginfo( 'name' ); ?gt;lt;/agt;lt;/h2gt; lt;?php endif; $superb_landingpage_description = get_bloginfo( 'description', 'display' ); if ( $superb_landingpage_description || is_customize_preview() ) : ?gt; lt;p class="site-description"gt;lt;?php echo $superb_landingpage_description; /* WPCS: xss ok. */ ?gt;lt;/pgt; lt;?php endif; ?gt; lt;/divgt; lt;/divgt;lt;!-- .site-branding --gt; lt;nav id="site-navigation" class="main-navigation large-8 medium-2 small-3 cell"gt; lt;?php wp_nav_menu( array( 'theme_location' =gt; 'menu-1', 'menu_id' =gt; 'primary-menu', ) ); ?gt; lt;/navgt;lt;!-- #site-navigation --gt; lt;/headergt;lt;!-- #masthead --gt; lt;/divgt; lt;/divgt; lt;?php if ( get_header_image() ) : ?gt; lt;?php if ( is_front_page() ) : ?gt; lt;div class="content-wrap"gt; lt;div class="bottom-header-wrapper"gt; lt;img src="lt;?php echo esc_url(( get_header_image()) ); ?gt;" alt="lt;?php echo esc_attr(( get_bloginfo( 'title' )) ); ?gt;" /gt; lt;/divgt; lt;/divgt; lt;?php endif; ?gt; lt;?php endif; ?gt; lt;div id="page" class="site grid-container start-container-head"gt; lt;a class="skip-link screen-reader-text" href="#content"gt;lt;?php esc_html_e( 'Skip to content', 'superb-landingpage' ); ?gt;lt;/agt; lt;div id="content" class="site-content grid-x grid-padding-x"gt;
Что мне добавить/удалить, чтобы заголовок отображался на всех страницах?
Я попытался удалить условия if/else в header.php но wordpress продолжает откатывать редактирование, утверждая об ошибках. Любая помощь будет очень признательна! Спасибо.
Комментарии:
1. Не могли бы вы отредактировать свой вопрос и включить в него весь
header.php
файл? На данный момент неясно, что происходит после этогоif
состояния. Такжеthe_custom_logo
функция находится внеif
условия! Я не думаю, что ваш логотип имеет какое-либо отношение кif
состоянию. Это неясно, пока вы не добавите весь файл или, по крайней мере, соответствующие разделы вашегоheader.php
файла.2. Выполнено. Спасибо.
Ответ №1:
Попробовать это
lt;?php if ( is_home() ) { // This is a homepage } else { // This is not a homepage } ?gt;
Ответ №2:
lt;?php if ( is_front_page() amp;amp; is_home() ) { // This is a homepage } else { // This is not a homepage } ?gt;
Если это не сработает, попробуйте это
lt;?php if ( is_front_page() ) { // This is a homepage } else { // This is not a homepage } ?gt;