Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am developing a WordPress theme and would like to make use of a custom header on a the homepage (I'm using a custom page template).

I would like this header to not include an image, but rather an <h1> and <h2> tag, and a link.

So my question is the following - how do I go about providing users with the facility to update the headings and the link in the header from the admin backend? Would add_theme_support( 'custom-header' ); be suitable for this since I need to add my own fields? And how would I go about completely disabling support for the image and showing the text in my page template?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

File: functions.php

It's as easy as adding this to your functions.php file (of course having $wpse67109 set).

add_theme_support( 'custom-header', $wpse67109_defaults );

File: index.php or any other template

Simply don't add the whole get_head_image() and get_custom_header()->foo stuff anywhere.

Your headline template part could look like the following example:

<header>
    <hgroup>
        <h1 class="site-title">
            <?php
            if ( display_header_text() )
            {
                printf(
                     '<a href="%s" title="%s" rel="home">%s</a>'
                    ,esc_url( home_url( '/' ) )
                    ,esc_attr( get_bloginfo( 'name', 'display' ) )
                    ,get_bloginfo( 'name' )
                );
            } 
            ?>
        </h1>
        <?php if ( '' !== get_bloginfo( 'description' ) ) : ?>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        <?php endif; ?>
    </hgroup>
</header>
share|improve this answer
1  
Thank you for your reply. Ok, I'll give this a shot - just to clarify though, '$wpse67109_defaults' is the name of the array you used to set the settings for the custom header right? –  Ian Muscat Oct 4 '12 at 11:52
    
@IanMuscat Right. I just prefix such stuff for questions in here. –  kaiser Oct 4 '12 at 11:54
    
Ok. I'll give this a try soon. Thank you... –  Ian Muscat Oct 4 '12 at 11:55
    
Hi, I tried out the example you provided me with - However I didn't get as far as I intended... While the code you gave above removes the image, I am still confused as to how I should insert my custom fields into the header area - I need to give the functionality to users to change the content that's in <h1> and <h2>. I found this tutorial - I'll give it a try and see where it takes me... –  Ian Muscat Oct 4 '12 at 12:28
    
@IanMuscat What? Why? Nooo°°.... ! Just use the theme customizer with above code ↑. It's as easy as that. –  kaiser Oct 4 '12 at 12:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.