最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Change header on one page in Wordpress

programmeradmin1浏览0评论

I need change the header image on just one page in Wordpress. We're using the ushuaia template, a child theme of wpcasa. It just uses a function.php page for everything. I've tried every plugin and none of them work for whatever reason. So I tried my hand at directly coding the change and added a 'forsale-image' argument to the code. It needs to go on the page 'for sale' or '8062'. Can anyone weigh in on how this should be done? Here's where the header image is created:

 add_filter( 'wpsight_custom_header_args', 'ushuaia_custom_header_args', 100 );

function ushuaia_custom_header_args( $args ) {

    $args['height']              = 490;
    $args['default-text-color']  = 'ffffff';
    $args['default-image']       = get_stylesheet_directory_uri() . '/images/header-image.png';
    $args['forsale-image']       = get_stylesheet_directory_uri() . '/images/LIV-SIR_BoR_Logo_600w.jpg';
    $args['wp-head-callback']    = 'ushuaia_header_style';

    return $args;

}

// gets included in the site header

function ushuaia_header_style() {
    $header_image = get_header_image(); 
    if( empty( $header_image ) )
        return;
    ?>
<style type="text/css">
#outer {
    background: url(<?php header_image(); ?>) no-repeat 30% -220px;
}
</style>

I need change the header image on just one page in Wordpress. We're using the ushuaia template, a child theme of wpcasa. It just uses a function.php page for everything. I've tried every plugin and none of them work for whatever reason. So I tried my hand at directly coding the change and added a 'forsale-image' argument to the code. It needs to go on the page 'for sale' or '8062'. Can anyone weigh in on how this should be done? Here's where the header image is created:

 add_filter( 'wpsight_custom_header_args', 'ushuaia_custom_header_args', 100 );

function ushuaia_custom_header_args( $args ) {

    $args['height']              = 490;
    $args['default-text-color']  = 'ffffff';
    $args['default-image']       = get_stylesheet_directory_uri() . '/images/header-image.png';
    $args['forsale-image']       = get_stylesheet_directory_uri() . '/images/LIV-SIR_BoR_Logo_600w.jpg';
    $args['wp-head-callback']    = 'ushuaia_header_style';

    return $args;

}

// gets included in the site header

function ushuaia_header_style() {
    $header_image = get_header_image(); 
    if( empty( $header_image ) )
        return;
    ?>
<style type="text/css">
#outer {
    background: url(<?php header_image(); ?>) no-repeat 30% -220px;
}
</style>
Share Improve this question asked Feb 15, 2020 at 14:46 Shannon DShannon D 1
Add a comment  | 

1 Answer 1

Reset to default 0

You want to use the following:

if (is_page( 806 ) ) {
  // Your code for that page here
}
发布评论

评论列表(0)

  1. 暂无评论