【发布时间】:2016-12-28 18:25:59
【问题描述】:
我正在使用 Genesis 框架构建一个站点。我在向每个页面添加自定义标题并使用管理区域中的特色图片链接发布时遇到了问题。现在,特色图片标题不会显示在我指定为“阅读”设置下的“博客”页面的页面上。
这是网站 URL,http://ajcustomfinishes.starfireclients.com/。
这是我正在使用的功能:
// 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
}
}
有人知道我如何使用特色图片在每个页面上显示自定义标题吗?
【问题讨论】: