Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.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 Wordpress Genesis主题使用特色图像显示自定义标题/背景图像_Php_Css_Wordpress_Genesis - Fatal编程技术网

Php Wordpress Genesis主题使用特色图像显示自定义标题/背景图像

Php Wordpress Genesis主题使用特色图像显示自定义标题/背景图像,php,css,wordpress,genesis,Php,Css,Wordpress,Genesis,我正在使用Genesis框架构建一个站点。我遇到了一个问题,在管理区使用特色图片链接向每个页面添加自定义标题和帖子。现在,在“阅读”设置下,我指定为“博客”页面的页面上不会显示特色图像标题 这是网站的URL 以下是我正在使用的函数: // Create new image size for our hero image add_image_size( 'hero-image', 1400, 400, TRUE ); // creates a hero image size // Hook af

我正在使用Genesis框架构建一个站点。我遇到了一个问题,在管理区使用特色图片链接向每个页面添加自定义标题和帖子。现在,在“阅读”设置下,我指定为“博客”页面的页面上不会显示特色图像标题

这是网站的URL

以下是我正在使用的函数:

// Create new image size for our hero image
add_image_size( 'hero-image', 1400, 400, TRUE ); // creates a hero image size

// Hook after header area
add_action( 'genesis_after_header', 'bw_hero_image' );

function bw_hero_image() {
// If it is a page and has a featured thumbnail, but is not the front page do the following...
    if (has_post_thumbnail() && is_page() ) {
        // Get hero image and save in variable called $background
        $image_desktop = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'hero-image' );
        $image_tablet = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'large' );
        $image_mobile = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'medium' );

        $bgdesktop = $image_desktop[0];
        $bgtablet = $image_tablet[0];
        $bgmobile = $image_mobile[0];

// You can change above-post-hero to any class you want and adjust CSS styles
        $featured_class = 'above-post-hero';

 ?> 
<div class='<?php echo $featured_class; ?>'><h1 class="custom-title">AJ Customs Finishes in Las Vegas<br>Call 702-795-7338 today!</h1></div>
<style>
    <?php echo ".$featured_class "; ?> {background-image:url( <?php echo $bgmobile; ?>);height:176px;}

        @media only screen and (min-width : 480px) {       
        <?php echo ".$featured_class "; ?> {background-image:url(<?php echo $bgtablet;?>);height:276px;}
        }
        @media only screen and (min-width : 992px) {       
        <?php echo ".$featured_class "; ?> {background-image:url(<?php echo $bgdesktop;?>);height:400px;}
        }
</style>
<?php
    } 
}
//为我们的英雄形象创建新的形象尺寸
添加图像大小(“英雄图像”,1400,400,真);//创建英雄图像大小
//收割台区域后挂钩
添加动作('genesis_后加标题','bw_hero_图像');
函数bw_hero_image(){
//如果它是一个页面,有一个特色缩略图,但不是头版,请执行以下操作。。。
if(has_post_缩略图()&&is_页面()){
//获取英雄图像并保存在名为$background的变量中
$image\u desktop=wp\u get\u attachment\u image\u src(get\u post\u缩略图\u id($page->id),'hero image');
$image\u tablet=wp\u get\u attachment\u image\u src(get\u post\u缩略图\u id($page->id),'large');
$image\u mobile=wp\u get\u attachment\u image\u src(get\u post\u缩略图\u id($page->id),'medium');
$bgdesktop=$image_desktop[0];
$bgtablet=$image_tablet[0];
$bgmobile=$image_mobile[0];
//您可以将上面的post hero更改为您想要的任何类,并调整CSS样式
$featured_class=‘高于后英雄’;
?> 
{背景图像:url();高度:176px;}
@仅介质屏幕和(最小宽度:480px){
{背景图像:url();高度:276px;}
}
@仅媒体屏幕和(最小宽度:992px){
{背景图像:url();高度:400px;}
}

您的代码中有此条件,如果在阅读设置中将页面设置为博客,则此条件将为FALSE:

    if (has_post_thumbnail() && is_page() ) {
is_page()在博客帖子主页(您在阅读中为帖子设置的页面)上将为false

您需要将此条件设置为“原样”_home()为真,即您可以将代码重新调整用途为:

    if (has_post_thumbnail() && is_page() || is_home()) {

您的代码中有此条件,如果在阅读设置中将页面设置为博客,则此条件将为FALSE:

    if (has_post_thumbnail() && is_page() ) {
is_page()在博客帖子主页(您在阅读中为帖子设置的页面)上将为false

您需要将此条件设置为“原样”_home()为真,即您可以将代码重新调整用途为:

    if (has_post_thumbnail() && is_page() || is_home()) {

非常感谢。非常有魅力。非常感谢。非常有魅力。