helencoupland
Member
Posted 2 years ago #
I'm trying to use a larger image on the homepage and a smaller version on all other pages.
I've created a version of the header.php file called header-home.php which refers to the image I want, but I can't work out how to apply the header-home.php to the homepage instead of the regular header.php. Presumably with some conditional tags but I don't know where to put these;
Is it in the index template which just looks like this
' <?php get_header(); ?>
<!-- Begin Blog -->
<?php include (THEMELIB . '/apps/blog.php'); ?>
<!-- Begin Footer -->
<?php get_footer(); ?>'
I'd edit my header.php file to have an if/then in it:
<?php if(is_home() ) {
//do special header stuff
} else {
//do regular header stuff
} ?>
helencoupland
Member
Posted 2 years ago #
Thanks for the help... My header.php file looks like this though (I started from a complicated theme and disabled a lot of stuff).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<title><?php wp_title( '-', true, 'right' ); echo wp_specialchars( get_bloginfo('name'), 1 ); ?></title>
<meta http-equiv="content-type" content="<?php bloginfo('html_type') ?>; charset=<?php bloginfo('charset') ?>" />
<meta name="description" content="<?php bloginfo('description') ?>" />
<?php if(is_search()) { ?>
<meta name="robots" content="noindex, nofollow" />
<?php }?>
<!-- Styles -->
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/library/styles/screen.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/library/styles/print.css" type="text/css" media="print" />
<!--[if IE]><link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/library/styles/ie.css" type="text/css" media="screen, projection" /><![endif]-->
<!--[if lte IE 7]><link type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/library/styles/ie-nav.css" rel="stylesheet" media="all" /><![endif]-->
<?php //Load Variables
$css = get_option('T_background_css');
?>
<?php if ($css == 'Enabled') {?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/library/functions/style.php" type="text/css" media="screen, projection" />
<?php } ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php if(function_exists('show_media_header')){ show_media_header(); } ?>
<body>
<div id="top">
<!-- Begin Masthead -->
<div id="masthead">
<h1><a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/eastern_soul_header.gif" title="<?php bloginfo('name'); ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
</div>
<?php include (TEMPLATEPATH . '/nav.php'); ?>
<div class="clear"></div>
</div>
<div class="container">
<div class="container-inner">
What is it you want to change? If it's just the masthead, then
<?php if(is_home() ) {
//do special header stuff
} else {
//do regular header stuff
<!-- Begin Masthead -->
<div id="masthead">
<h1><a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/eastern_soul_header.gif" title="<?php bloginfo('name'); ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
</div>
<?php include (TEMPLATEPATH . '/nav.php'); ?>
} ?>
See how that works? :)
helencoupland
Member
Posted 2 years ago #
Sorry no.. I used the code below, but I keep getting this error:
Parse error: syntax error, unexpected '<' in /home/heloucou/public_html/niraj/wp-content/themes/modularity-lite/header.php on line 39
<?php if(is_home() ) {
//do special header stuff
<div id="masthead">
<h1><a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/eastern_soul_header_home.gif" title="<?php bloginfo('name'); ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
</div>
<?php include (TEMPLATEPATH . '/nav.php'); ?>
} else {
//do regular header stuff
<div id="masthead">
<h1><a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/eastern_soul_header.gif" title="<?php bloginfo('name'); ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
</div>
<?php include (TEMPLATEPATH . '/nav.php'); ?>
} ?>
You have a PHP include in your PHP code. Try this:
<?php if(is_home() ) {
//do special header stuff
?>
<div id="masthead">
<h1><a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/eastern_soul_header_home.gif" title="<?php bloginfo('name'); ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
</div>
<?php include (TEMPLATEPATH . '/nav.php'); ?>
<?php
} else {
//do regular header stuff
?>
<div id="masthead">
<h1><a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/eastern_soul_header.gif" title="<?php bloginfo('name'); ?>" alt="<?php bloginfo('name'); ?>" /></a></h1>
</div>
<?php include (TEMPLATEPATH . '/nav.php'); ?>
<?php
} ?>
helencoupland
Member
Posted 2 years ago #
That works fine... Thank you!