我遇到过一个我无法通过浏览这些论坛和其他论坛来解决的问题。
我使用以下代码将我的网页精选图片用作标题背景图片,并使用下面的代码生成自定义网站标题和说明。
正在发生的事情是自定义网站标题和说明显示在特色标题图像下方。我假设这是因为标题图像现在位于yogaweb_featured_header而不是genesis_header,而我的自定义网站标题和描述的代码仍然试图将它放在genesis_header而不是yogaweb_featured_header。
任何建议或答案都将是一个巨大的帮助。
特色图片PHP
remove_action( 'genesis_header', 'genesis_do_header' );
add_action( 'genesis_header', 'yogaweb_featured_header' );
//ADD FEATURED IMAGE TO HEADER
function yogaweb_featured_header() {
if( is_singular( 'page' ) ) {
global $post;
$size = 'full-size';
$default_attr = array(
'class' => "aligncenter attachment-$size $size",
'alt' => $post->post_title,
'title' => $post->post_title,
);
printf( '<div class="example">%s</div>', genesis_get_image( array( 'size' => $size, 'attr' => $default_attr ) ) );
}
}
// CHANGE DIMENSIONS BELOW TO FIT YOUR THEME
add_image_size('cover', TRUE);
add_filter( 'image_size_names_choose', 'my_custom_image_sizes_choose' );
function my_custom_image_sizes_choose( $sizes ) {
$custom_sizes = array(
'cover' => 'cover',
);
return array_merge( $sizes, $custom_sizes );
}
自定义标题和描述PHP
// Custom Site Title
// Filter the title with a custom function
add_filter('genesis_seo_title', 'yoga_site_title' );
// Add additional custom style to site header
function yoga_site_title( $title ) {
// Change $custom_title text as you wish
$custom_title = '<span class="site-title">Yogaisaweso.me</span>';
// Don't change the rest of this on down
// If we're on the front page or home page, use `h1` heading, otherwise us a `p` tag
$tag = ( is_home() || is_front_page() ) ? 'h1' : 'h1';
// Compose link with title
$inside = sprintf( '<a href="%s" title="%s">%s</a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), $custom_title );
// Wrap link and title in semantic markup
$title = sprintf ( '<%s class="site-title" itemprop="headline">%s</%s>', $tag, $inside, $tag );
return $title;
}
// First line of Header text
//* Remove the tag line / site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
add_action( 'genesis_site_description', 'child1_seo_site_description' );
/**
* Change the site description (also called tagline)
* to include html code.
* Remove description, add whatever change you want to make.
* Then add description back to header.
*/
function child1_seo_site_description() {
echo '<h2 id="description1">ELEVATED THROUGH COMMUNITY</h2>';
}
// Second Line of Header Content
add_action( 'genesis_site_description', 'child2_seo_site_description' );
/**
* Change the site description (also called tagline)
* to include html code.
* Remove description, add whatever change you want to make.
* Then add description back to header.
*
* @author Terry Collins
* @since 1.0.0
*/
function child2_seo_site_description() {
echo '<div class="center-icon"><div class="one-third first" id="description2">
<i id="fa-head" class="fa fa-paint-brush fa-3x"></i><br>CREATE</div>
<div class="one-third" id="description2">
<i id="fa-head" class="fa fa-heart fa-3x"></i><br>INSPIRE</div><div class="one-third" id="description2">
<i id="fa-head" class="fa fa-tree fa-3x"></i><br>GROW</div></div>';
}
提前致谢所有帮助