Pro Theme Design Forum » Mimbo Pro » Technical Help

Different header for different categories

  • Started 2 years ago by Q-design
  • Latest reply from robin
  • This topic is not a support question

I'd like to know if I can change the top header using this snippet:

< ? php $category = get_the_category();

echo '<div class="category' . $category[0]->cat_ID . '"> ;? >

I saw that in header.php there is another if...else depending on is_ome.

Can I integrate my code with the existing one?

  • Ben
  • Ben
  • Posted 2 years ago #

Hi - I'm not sure what you're asking. Could you be a bit clearer please?

Well, I write a worst English...

I try to explain:

In my website I have lot of categories and I have lot of headers (1 for category). I'd like to mantain this behaviour using your Wordpress theme.

Do you kow if this is possible?

  • robin
  • Member
  • Posted 2 years ago #

I do the same for specific posts and pages and used following code for it in the header.php:

<?php }
$bannerimg="bg_masthead.jpg";

if (is_page('252') ) {
   $bannerimg="bg_masthead_video.jpg";
} elseif (is_home() ) {
   $bannerimg="bg_masthead_home.jpg";
} elseif (is_page('253') ) {
   $bannerimg="bg_masthead_video.jpg";
} elseif (is_single('27') ) {
   $bannerimg="bg_masthead_27.jpg";
}
?>

Guess you can apply the same for categories in this way?

  • Roccofs
  • Member
  • Posted 2 years ago #

Can somebody explain this solution "for real dummies" style? Plz?

  • Marius
  • Member
  • Posted 2 years ago #

" do the same for specific posts and pages and used following code for it in the header.php:"

Where exactly in header.php and how do you do that for categories?

  • darren
  • admin
  • Posted 2 years ago #

Check out the Codex section on conditionals. Robin's suggestion is a good one (Robin can you explain where you placed that code?) - you can use conditionals to determine which masthead to correspond with what post by its ID number.

  • robin
  • Member
  • Posted 2 years ago #

Since wp 2.5 I used arrays instead if more then one page needed the same headerimage, Below i copied in some more code which should make it easier to see were to paste it.
All my header images are located in the mimbopro_single/images folder.

Below piece of code is taken directly from header.php (hope it displays well.) I started to copy somewere from line 93.

<?php if( get_option( "bm_logo" ) == 1 ) { ?>
<style type="text/css">
#masthead h1, a#logo {
text-indent:-9999px;
width:320px;
height:108px;
background:url( <?php bloginfo('template_url'); ?>/images/logo.gif ) no-repeat;
margin:0 auto;
display:block;
color:#FFF;
}
#masthead h2 {
display:none;
}
</style>

<?php }
$bannerimg="bg_masthead.jpg";

if (is_page(array(252,253))) {
$bannerimg="bg_masthead_video.jpg";
} elseif (is_home() ) {
$bannerimg="bg_masthead_home.jpg";
} elseif (is_page(array(251,254))) {
$bannerimg="bg_masthead_foto.jpg";
} elseif (is_category('9') ) {
$bannerimg="bg_masthead_video.jpg";
} elseif (is_single('26') ) {
$bannerimg="bg_masthead_26.jpg";
}

?>
<style type="text/css">
#masthead {
background-image: url( /wp-content/themes/mimboPro_single/images/<?php echo $bannerimg; ?>);
}
</style>

<?php wp_head(); ?>
</head>

<body<?php if (is_home()) { ?> id="home"<?php } else { ?> class="page-<?php echo $post->post_name; ?>" id="interior"<?php } ?>>

<div id="printMessage"></div>

<div id="page">

Reply

You must log in to post.