Roating Header Image Based On Category
-
Hey,
I am trying to show a different custom header image for every category.
Here is what I currently use:
<!-- Start Custom Header Images - Shows Background Image Based on Category -->
<div id="header" <?php if ( in_category(3) ) { echo 'style="background: #fff url(/wp-content/themes/connections/img/header_99updates.gif) no-repeat bottom;"'; } else if (in_category (5) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_01updates.gif) no-repeat bottom;"'; } else if (in_category (7) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_03updates.gif) no-repeat bottom;"'; } else if (in_category (4) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_00updates.gif) no-repeat bottom;"'; } else if (in_category (6) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_02updates.gif) no-repeat bottom;"'; } else if (in_category (8) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_04updates.gif) no-repeat bottom;"'; } else if (in_category (9) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_05updates.gif) no-repeat bottom;"'; } else if (in_category (10) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_06updates.gif) no-repeat bottom;"'; } else if (in_category (2) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_98updates.gif) no-repeat bottom;"'; } else if (in_category (11) ) {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_newsletter.gif) no-repeat bottom;"'; } else {echo 'style="background: #fff url(/wp-content/themes/connections/img/header_main.gif) no-repeat bottom;"'; } ?>>
<!-- End Custom Header Images -->I am sure there must be a cleaner and better way. Any ideas?
Thanks a lot,
Will
The topic ‘Roating Header Image Based On Category’ is closed to new replies.