• I am hoping to set different header images for each page or category. As I haven’t decided/created my template yet so feel that putting css code on each page would be the best option but where do I start! Very basic CSS knowledge only.

Viewing 2 replies - 1 through 2 (of 2 total)
  • if these images are planned as background images, then using conditional statements to create embedded styles in hedader.php is a viable way.

    https://codex.www.ads-software.com/Conditional_Tags

    is_page()
    is_category()
    in_category()

    just as an example for a possible structure – added to header.php, before </head> :

    <style type="text/css" media="screen">
    
    <?php if ( is_page('pagename') ) { ?>
    #header_img { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/pagename_img.jpg") center top no-repeat; }
    <?php } elseif( is_page('pagename2') ) { ?>
    #header_img { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/pagename2_img.jpg") center top no-repeat; }
    <?php else { ?>
    #header_img { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/default_img.jpg") center top no-repeat; }
    <?php } ?>
    </style>

    or check this semi-automated method

    ps:
    also consider using ‘body_class()’
    https://codex.www.ads-software.com/Template_Tags/body_class
    to generate extra classes, which you might be able to use in the styles of the pages;

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different Header Images per page’ is closed to new replies.