Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使217使用两个不同的标题图像的帖子&;头版_Php_Html_Css_Wordpress_Image - Fatal编程技术网

Php 如何使217使用两个不同的标题图像的帖子&;头版

Php 如何使217使用两个不同的标题图像的帖子&;头版,php,html,css,wordpress,image,Php,Html,Css,Wordpress,Image,我在“217”主题中遇到的问题是,同一个图像用于首页,它覆盖了整个屏幕,而用于帖子/页面,其中仅显示了约20%的图像。这使得它不可能使头版和帖子标题看起来都像样。我需要将它们分开,这样头版可以得到一张图片,而帖子/页面可以得到另一张。我应该在哪里改变这一点 以下是标题代码: <header id="masthead" class="site-header" role="banner"> <?php get_template_part( 'template-pa

我在“217”主题中遇到的问题是,同一个图像用于首页,它覆盖了整个屏幕,而用于帖子/页面,其中仅显示了约20%的图像。这使得它不可能使头版和帖子标题看起来都像样。我需要将它们分开,这样头版可以得到一张图片,而帖子/页面可以得到另一张。我应该在哪里改变这一点

以下是标题代码:

    <header id="masthead" class="site-header" role="banner">

    <?php get_template_part( 'template-parts/header/header', 'image' ); ?>

    <?php if ( has_nav_menu( 'top' ) ) : ?>
        <div class="navigation-top">
            <div class="wrap">
                <?php get_template_part( 'template-parts/navigation/navigation', 'top' ); ?>
                    <?php if ( has_nav_menu( 'social' ) ) : ?>
                    <nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Social Links Menu', 'twentyseventeen' ); ?>">
                    <?php
                        wp_nav_menu( array(
                            'theme_location' => 'social',
                            'menu_class'     => 'social-links-menu',
                            'depth'          => 1,
                            'link_before'    => '<span class="screen-reader-text">',
                            'link_after'     => '</span>' . twentyseventeen_get_svg( array( 'icon' => 'chain' ) ),
                        ) );
                    ?>
                </nav><!-- .social-navigation -->
                <?php endif; ?>
            </div><!-- .wrap -->
        </div><!-- .navigation-top -->
    <?php endif; ?>

</header><!-- #masthead -->

“获取模板”部分中使用的标题模板:

<div class="custom-header">

    <div class="custom-header-media">
        <?php the_custom_header_markup(); ?>
    </div>

<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>


与任何其他页面相比,在头版使用不同照片的方法只需使用以下内容:

if (is_front_page()) {
  // Code for front-page image
} else {
  // Code for all other template pages
}

我想这就是你想要的,但是,你的问题可以用很多不同的方式来解释,例如,我如何使用Wordpress admin来添加不同的图像,或者我应该使用什么CSS/如何使用它来获得预期的结果…

如果它是背景图像(听起来像是),你可以用纯CSS来解决这个问题。只用

body {
  background-image: url('image_x.jpg');
}
对于常规页面和(按该顺序)


对于主页(将
.home
类自动应用于主页的
正文
标记)

a。我们不知道这个星球上的每一个主题,b。我们真的需要一个链接,以便能够理解你所看到的c。这纯粹是一个html\css问题。我们需要看到生成的html\css,而不是PHPUN。幸运的是,创建的是\u custom\u header\u markup()或其他东西,而不是使用css作为div本身。所以我需要使用您注释中的代码进行更改,对吗?我相信这个函数会在div内部创建。如果成功,我会尝试并报告。是的,但您必须手动在那里插入图像。您可以使用wordpress中的媒体上传程序上传图像,并在代码中复制/粘贴链接,也可以将其放入主题中的/images/文件夹中,并使用以下示例代码:/images/yourmage.jpg“>我成功了,现在头版有一张图片,另一张图片,但由于某种原因,url被不同的斜杠弄得一团糟:你知道为什么会发生这种情况吗?这是wordpress函数自动生成的代码吗?该路径应与本地服务的安装路径相关-预期结果类似于“‌​ages/headerbg.png”。我想这与你的wordpress evniroment设置或xamp配置设置有关。get_template_directory_uri()是我在本地环境中必须使用的。
body.home {
  background-image: url('image_homepage.jpg');
}