Help with functions.php for custom image header
-
Hello,
I’ve been building a theme, and I’d like it to have a custom image header that can be changed from the admin panel.I’ve got most of it to work, but when I log in to the admin, the default header image doesn’t show where it says:
“This is your header image. You can change the text color or upload and crop a new image.”
I can hide the text, and upload a new header image, but it when I change the text color, only the blog description tag changes. The H1 doesn’t change.
Here’s the function.php code:
// Set some default values
define(‘HEADER_TEXTCOLOR’, ‘#ededed’); // Default text color
define(‘HEADER_IMAGE’, ‘%s/images/headerimage1.jpg’); // %s is theme dir uri, set a default image
define(‘HEADER_IMAGE_WIDTH’, 1000); // Default image width is actually the div’s height
define(‘HEADER_IMAGE_HEIGHT’, 163); // Same for heightfunction header_style() {
// This function defines the style for the theme
// You can change these selectors to match your theme
?>
<style type=”text/css”>
#header{
background:#24313b url(<?php header_image() ?>) no-repeat;
}
<?php
// Has the text been hidden?
// If so, set display to equal none
if ( ‘blank’ == get_header_textcolor() ) { ?>
#headertext h1, #menu h2 {
display: none;
}
<?php } else {
// Otherwise, set the color to be the user selected one
?>
#headertext h1 a, #menu h2 {
color:#<?php header_textcolor() ?>;
}
<?php } ?>
</style>
<?php
}function crev_admin_header_style() {
?>
<style type=”text/css”>
#header{
background: #24313b url(<?php header_image() ?>) no-repeat;
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
width:<?php echo HEADER_IMAGE_WIDTH; ?>px;
padding:0;
}#headertext h1 a{
color:#<?php header_textcolor() ?>;
text-decoration:none;
}
#menu h2{
color:#<?php header_textcolor() ?>;}
<?php if ( ‘blank’ == get_header_textcolor() ) { ?>
#headertext h1, #menu h2 {
display: none;
}
#headertext h1 a, #menu h2 {
color:#<?php echo HEADER_TEXTCOLOR ?>;
}
<?php } ?></style>
<?php
}add_custom_image_header(‘header_style’, ‘crev_admin_header_style’);
?>
And here’s a link to the theme on my test blog:
http://silentskydesign.com/wordpresstest/?wptheme=Silver%20Night
Thank you for your help
The topic ‘Help with functions.php for custom image header’ is closed to new replies.