Skip to content

Instantly share code, notes, and snippets.

@frontend-coder
Last active June 2, 2022 07:25
Show Gist options
  • Save frontend-coder/6e4aaf7513f0f5bbb463766209c41139 to your computer and use it in GitHub Desktop.
Save frontend-coder/6e4aaf7513f0f5bbb463766209c41139 to your computer and use it in GitHub Desktop.
29.Кастомайзер. Довільний header сайту #wordpress
register_default_headers( array(
'wheel' => array(
'url' => get_template_directory_uri().'/assets/img/header.jpg',
'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
'description' => __( 'Wheel', 'twentyeleven' )
),
'shore' => array(
'url' => '%s/images/headers/shore.jpg',
'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
'description' => __( 'Shore', 'twentyeleven' )
),
'trolley' => array(
'url' => '%s/images/headers/trolley.jpg',
'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
'description' => __( 'Trolley', 'twentyeleven' )
)
) );
OR
register_default_headers( array(
'default-image' => array(
'url' => get_template_directory_uri().'/assets/img/header.jpg',
'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
'description' => __( 'Wheel', 'domain' )
)));
add_theme_support( 'custom-header', array(
'default-image' => get_template_directory_uri().'/assets/img/header.jpg',
'random-default' => false,
'width' => 1900,
'height' => 700,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => 'ffffff', // вызывается функций get_header_textcolor()
// 'header-text' => true,
// 'uploads' => true,
// 'wp-head-callback' => '',
// 'admin-head-callback' => '',
// 'admin-preview-callback' => '',
'video' => false, // с 4.7
'video-active-callback' => 'is_front_page', // с 4.7
) );
<?php $img = has_custom_header() ? get_header_image() : get_custom_header()->url; ?>
<section style="background:url(<?php echo $img; ?>); <?php echo sprintf('color:#%s', get_header_textcolor()); ?>"
// get_header_textcolor() перебиває стилі в файлі css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment