• Resolved ke vinritt

    (@ke-vinritt)


    I have a conditional statement that will apply headers to different categories. However, it also applies it to the homepage. How can I exclude the homepage from this:

    <?php if (is_page('4')) { ?>
                <img src="<?php bloginfo('template_url'); ?>/headers/academy-header.jpg" width="960" height="152" alt="<?php bloginfo('name'); ?> The Academy" />
                <?php } elseif (is_page('8')) { ?>
                <img src="<?php bloginfo('template_url'); ?>/headers/shining-header.jpg" width="960" height="152" alt="<?php bloginfo('name'); ?> Shining Star" />
                <?php } else { ?>
                <img src="<?php bloginfo('template_url'); ?>/headers/default-header.jpg" width="960" height="152" alt="<?php bloginfo('name'); ?> Rotating Header Image" title="<?php bloginfo('name'); ?> MCAEC" />
                <?php } ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try this:

    <?php if (is_page('4')) { ?>
                <img src="<?php bloginfo('template_url'); ?>/headers/academy-header.jpg" width="960" height="152" alt="<?php bloginfo('name'); ?> The Academy" />
                <?php } elseif (is_page('8')) { ?>
                <img src="<?php bloginfo('template_url'); ?>/headers/shining-header.jpg" width="960" height="152" alt="<?php bloginfo('name'); ?> Shining Star" />
                <?php } else {
                if(!is_home()){ ?>
                <img src="<?php bloginfo('template_url'); ?>/headers/default-header.jpg" width="960" height="152" alt="<?php bloginfo('name'); ?> Rotating Header Image" title="<?php bloginfo('name'); ?> MCAEC" />
                <?php }} ?>

    maybe you can use something from the script i made:

    php:

    <?php
    if (is_front_page()) {
       $header = 'header_home';
    }
    elseif (in_category('Beeldbewerking')) {
       $header = 'header_beeldbewerking';
    }
    elseif (in_category('Communicatie')) {
       $header = 'header_communicatie';
    }
    elseif (in_category('Communicatie')) {
       $header = 'header_communicatie';
    }
    elseif (in_category('Design')) {
       $header = 'header_design';
    }
    elseif (in_category('Drukwerk')) {
       $header = 'header_drukwerk';
    }
    elseif (in_category('DTP smartness')) {
       $header = 'header_dtp';
    }
    elseif (in_category('Fotografie')) {
       $header = 'header_fotografie';
    }
    elseif (in_category('Guerrilla')) {
       $header = 'header_guerrilla';
    }
    elseif (in_category('Krokant!')) {
       $header = 'header_krokant';
    }
    elseif (in_category('Marketing')) {
       $header = 'header_marketing';
    }
    elseif (is_category ('Ons werk')) {
       $header = 'header_onswerk';
    }
    elseif (is_single() && in_category ('Ons werk')) {
       $header = 'header_onswerk';
    }
    elseif (in_category('Regio')) {
       $header = 'header_regio';
    }
    elseif (in_category('Social media')) {
       $header = 'header_socialmedia';
    }
    elseif (in_category('Strikje erom')) {
       $header = 'header_strikjeerom';
    }
    elseif (in_category('Typografie')) {
       $header = 'header_typografie';
    }
    elseif (in_category('Webdesign')) {
       $header = 'header_webdesign';
    }
    elseif (is_home()) {
       $header = 'header_home';
    }
    elseif (is_page('Home')) {
       $header = 'header_home';
    }
    elseif (is_page('Actie')) {
       $header = 'header_actie';
    }
    elseif (is_page('Ons werk')) {
       $header = 'header_home';
    }
    elseif (is_page('Contact')) {
       $header = 'header_home';
    }
    elseif (is_page('Nieuwsbrief')) {
       $header = 'header_home';
    }
    elseif (is_page('FTP')) {
       $header = 'header_home';
    }
    elseif (is_page('Vacatures')) {
       $header = 'header_home';
    }
    elseif (is_page('Colofon')) {
       $header = 'header_home';
    }
    elseif (is_page('Links')) {
       $header = 'header_home';
    }
    else {
       $header = 'header_home';
    }
    
    ?>
    
    <?php echo ' class="', $header, '"'; ?>>

    css:

    .header_socialmedia {
    	height: 230px;
    	width: 960px;
    	background-image: url(images/header_socialmedia.jpg);
    	background-repeat: no-repeat;
    }

    Thread Starter ke vinritt

    (@ke-vinritt)

    Thanks keesiemeijer,
    That worked

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘use header images except on homepage’ is closed to new replies.