Why this code works fine:
<?php if (**is_page**('4')) { ?>
<style type="text/css">
body {background-image:url("<?php bloginfo('template_url'); ?>/images/bac4.jpg");}
</style>
<?php } else ?>
and this not:
<?php if (**is_category**()) { ?>
<style type="text/css">
body {background-image:url("<?php bloginfo('template_url'); ?>/images/coaching.jpg");}
</style>
<?php } else ?>
Works for me in my template's header.php. Add some stuff to your template's archive.php, preferably inside the is_category()
, to verify you're on a category page. Also, I find the alternative if syntax easier to read and debug, but YMMV.
if( is_category() ):
?>
<!-- some html -->
<?php
else:
?>
<!-- other -->
<?php
endif;