【问题标题】:Building Theme From Scratch – Header Not Showing从头开始构建主题 - 标题未显示
【发布时间】:2017-11-03 08:41:30
【问题描述】:

我正在从头开始创建一个网站,但我的自定义标题没有显示。

这是我的 css 代码:

/*
* Blog name and description
*/
   #mainheader {
    height: 100%;
    padding-top: 100px;
    padding-bottom: 100px;
    } 
    .blog-header {
    width: 100%;
    height: 100%;
    padding-top: 25px;
    padding-bottom: 25px;
    }

这是我的标头代码:

<body>
  <header id="mainheader">
   <div class="blog-header">
    <div id="blog-img">
    </div>
   </div>
  </header>
<div class="container">

这是我的 function.php 代码:

// Support Featured Images
add_theme_support( 'post-thumbnails' );
//Add Custom header Settings
$args = array(
    'width'         => 1920,
    'height'        => 1080,
    'default-image' => get_template_directory_uri() . '/images/headers/lofsw.png',
    'uploads'       => true,
);
add_theme_support( 'custom-header', $args );

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    您需要在页面模板中调用函数get_header(),并确保您的标题代码位于名为header.php 的文件中。这是 index.php 文件的示例。

    <?php get_header(); ?>
    
    <div class="container-wrap">
    		
    	<div class="container main-content">
    		
    		<div class="row">
        
        </div>
      </div>
    </div>
    
    <?php get_footer(); ?>

    【讨论】:

    • 我的标头代码应该是什么?因为我已经有了 在我的 index.php 上
    • HTML 标头代码进入主题目录中的 header.php 文件。
    • 我实际上找到了一种通过添加 theme.phpget_header_image 来显示它的方法。我现在的问题是标题占据了整个网站。如何将其设置为“固定”尺寸?
    • 这没有使用 WordPress 主题的约定。最好坚持标准方式。
    猜你喜欢
    • 2017-12-18
    • 2014-03-03
    • 2018-07-12
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    相关资源
    最近更新 更多