WordPress.org

Ready to get started?Download WordPress

Forums

Custom Header Image/Text (2 posts)

  1. lilqhgal
    Member
    Posted 4 years ago #

    I am designing a theme for public use. I have set it up following tutorials I have found on the web and it works allowing a custom image to be uploaded and cropped and lets the user pick the color text (or hide text).

    However, having that said, I only want to allow the user to change the header image. I don't want to offer custom font colors. The ability to turn the text off is fine.

    Here is part of my functions.php file:

    define('HEADER_IMAGE', '%s/images/header.jpg'); // %s is theme dir uri
    define('HEADER_IMAGE_WIDTH', 700);
    define('HEADER_IMAGE_HEIGHT', 170);
    define('HEADER_TEXTCOLOR', 'FFF');
    
    function admin_header_style() { ?>
    <style type="text/css">
    
    #header {
    	background: url(<?php header_image();?>) 0 0 no-repeat;
    	height: <?php echo HEADER_IMAGE_HEIGHT;?>px;
    	width: <?php echo HEADER_IMAGE_WIDTH;?>px;
    	position: relative;
    }
    
    <?php if ( 'blank' == get_header_textcolor() ) { ?>
    #header h1 a, { display: none; }
    #header .description { display: none; }
    
    <?php } else { ?>  
    
    #header {
    	margin: 0px;
    	font-size:30px;
    	text-transform:uppercase;
    	font-family: Georgia;
    }
    
    <?php } ?>
    
    </style>
    <?php }
    
    function header_style() { ?>
    <style type="text/css">
    
    #header {
    background: url(<?php header_image();?>) no-repeat;
    height: <?php echo HEADER_IMAGE_HEIGHT;?>px;
    width: <?php echo HEADER_IMAGE_WIDTH;?>px;
    position: relative;
    }
    
     <?php if ( 'blank' == get_header_textcolor() ) {?>
    #header h1 a, #header .description { display: none; }
    
    <?php } ?>
    </style>
    <?php }
    
    if ( function_exists('add_custom_image_header') ) {
      add_custom_image_header('header_style', 'admin_header_style');
    }

    So far, I can overwrite the end result of the text color so that it will not let the user change it, but the instructions in the admin still say "click here to change your text color". I am trying to figure out how to remove that functionality all together. Any help is appreciated!

  2. CallMeMisterX
    Member
    Posted 3 years ago #

    Two things:
    In your fourth line, change
    define('HEADER_TEXTCOLOR', 'FFF');
    to . . .
    define('HEADER_TEXTCOLOR', '');

    The second thing, add . . .

    define('NO_HEADER_TEXT', true );

    . . . just below that, and you should be good!

Topic Closed

This topic has been closed to new replies.

About this Topic