• Hi,

    I have used the following to add different banners depending on a page ID, it works fine displays the correct image on the correct page. However i can’t seem to get the code right to link the images. Does anyone know what i need to add to link the images depending on the page ID?

    <?php
    if( is_page(116) ) {
    	$img = 'image1.gif';
    	$alt = 'image 1';
    } else {
    	$img = 'image2.gif';
    	$alt = 'image 2';
    }
    ?>
    <img src="<?php echo $img; ?>" alt="<?php echo $alt; ?>" />
Viewing 3 replies - 1 through 3 (of 3 total)
  • Try using absolute image URLs. See here:

    http://wordpress.org/support/topic/175947

    Thread Starter shaun1981

    (@shaun1981)

    I appear to have got it working by adding the following

    <?php
    if( is_page(116) ) {
    	$img = 'image1.gif';
    	$alt = 'image 1';
             $link = 'link.html';
    } else {
    	$img = 'image2.gif';
    	$alt = 'image 2';
             $link = 'link2.html';
    }
    ?>
    <a href="<?php echo $link; ?>"><img src="<?php echo $img; ?>" alt="<?php echo $alt; ?>" /></a>

    Hi,

    Can anyone explain a bit more about this? where to add the code etc. I want to use it with the kubrick theme. Been playing around but cant seem to get it to work.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Conditional tags – little help needed’ is closed to new replies.