0

我遇到了一个问题,我似乎无法通过浏览这些论坛和其他论坛来解决。

我正在使用以下代码将我的页面特色图像用作标题背景图像,并使用下面的代码生成自定义站点标题和描述。

发生的情况是自定义站点标题和描述显示在特色标题图像下方。我假设这是因为标题图像现在位于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>';

 }

提前感谢所有帮助

4

0 回答 0