php - 在所有页面上显示 Wordpress 标题,而不仅仅是首页
问题描述
寻求帮助以使我的 wordpress 主题在所有页面上显示标题图像,而不仅仅是当前的主页。所有页面都使用 get_header php 命令,header.php 包含以下代码:
<?php
/**
* The header for our theme
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Superb_Landingpage
*/
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div class="navigation-wrapper">
<div class="site grid-container">
<header id="masthead" class="site-header grid-x grid-padding-x">
<div class="site-branding large-4 medium-10 small-9 cell">
<?php
the_custom_logo();
if ( is_front_page() && is_home() && is_page() ) :
?>
<div class="logo-container">
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php
else :
?>
<div class="logo-container">
<h2 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h2>
<?php
endif;
$superb_landingpage_description = get_bloginfo( 'description', 'display' );
if ( $superb_landingpage_description || is_customize_preview() ) :
?>
<p class="site-description"><?php echo $superb_landingpage_description; /* WPCS: xss ok. */ ?></p>
<?php endif; ?>
</div>
</div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation large-8 medium-2 small-3 cell">
<?php
wp_nav_menu( array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
) );
?>
</nav><!-- #site-navigation -->
</header><!-- #masthead -->
</div>
</div>
<?php if ( get_header_image() ) : ?>
<?php if ( is_front_page() ) : ?>
<div class="content-wrap">
<div class="bottom-header-wrapper">
<img src="<?php echo esc_url(( get_header_image()) ); ?>" alt="<?php echo esc_attr(( get_bloginfo( 'title' )) ); ?>" />
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<div id="page" class="site grid-container start-container-head">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'superb-landingpage' ); ?></a>
<div id="content" class="site-content grid-x grid-padding-x">
我要添加/删除什么来简单地在所有页面上显示标题?
我尝试删除 header.php 中的 if/else 条件,但 wordpress 不断回滚编辑声明错误。任何帮助是极大的赞赏!谢谢你。
解决方案
试试看
<?php
if ( is_home() ) {
// This is a homepage
} else {
// This is not a homepage
}
?>
推荐阅读
- html - 如何使角度材质卡占用可用的垂直空间并使其内容可滚动
- puppeteer - 如何在 puppeteer 中处理多个窗口?
- javascript - 从休息 api 获取数据的麻烦
- node.js - 如何从回调中返回值?
- typescript - 类型转换后的 TypeScript“不是构造函数类型”错误
- iis - 可以在证书存储中安装证书,但不能在 IIS 绑定列表中
- python - 在 Python 3.7 上运行 OpenGL 代码时出错
- reactjs - 如何为 React Bootstrap Typeahead 组件设置自定义高度?
- java - 使用 Base64 编码时,哪个字符串可能会给出 UnsupportedEncodingException
- python - pyautogui.pixelMatchesColor 怎么不能正常工作?