固定ページの、ヘッダー画像を、カスタマイズして、そのページ特有の画像を使う方法です。 functions.phpの先頭に(<?phpの前に、以下のコードを貼り付けてください。 your settingsの部分は、それぞれの環境に応じて、書き換えてください。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?php add_filter( 'raindrops_header_image_css','my_custom_header'); function my_custom_header( $style ){ /* your settings */ $apply_pages = array( 2152 ); // page id or slug or title ex array( 42, 'about-me', 'About Me And Joe' ) /* your settings end */ if( is_page( $apply_pages ) ){ /* your settings */ $img = 'http://www.example.com/images/example.jpg'; $height = ''; //example value 300px ,if you need height, please add !important $style = 'border:3px solid red; box-sizing: border-box;'; //ifyou need own style /* your settings */ $css = '#%1$s{background-image:url(%2$s )!important;height:%3$s;%4$s}'; $css = sprintf( $css, 'header-image', esc_url( $img ), esc_html( $height ), esc_html( $style ) ); return $css; } return $style; } ?> |
for English user