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?
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="https://wordpress.stackexchange.com/questions/67109/%s" title="https://wordpress.stackexchange.com/questions/67109/%s" rel="home">%s</a>'
,esc_url( home_url( "https://wordpress.stackexchange.com/" ) )
,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>