Title: Image and IF function
Last modified: August 19, 2016

---

# Image and IF function

 *  [aslamp](https://wordpress.org/support/users/aslamp/)
 * (@aslamp)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/image-and-if-function/)
 * Is it posible to add If fonction to a picture ?
    Like IF pageid=something it 
   shows one picture and If pageid=somethingelse it shows another picture ?

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

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/image-and-if-function/#post-1407353)
 * You can write that kind of thing into your theme but I’m not sure what you mean
   by adding the function “to a picture”.
 *  Thread Starter [aslamp](https://wordpress.org/support/users/aslamp/)
 * (@aslamp)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/image-and-if-function/#post-1407434)
 * I want a different picture to show in every page. 1 picture in home. 1 picture
   in contact, one picture in about etc.
    [http://vetech.no/wp/?page_id=148](http://vetech.no/wp/?page_id=148)
 * The image above the page content is now the same on every page. I would like 
   it to show one picture if page_id=148 and another picture if ?page_id=18.
 *  Thread Starter [aslamp](https://wordpress.org/support/users/aslamp/)
 * (@aslamp)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/image-and-if-function/#post-1407457)
 * at the moment this div defines the picture under the menu.
    <div class=”bilde2″
   ></div> I tryed this code, but that just crashed the site. It might give you 
   and idea about what im after 🙂
 *     ```
       <?php
       if ($page_id="18")
         echo "<div class="bilde2"></div>";
       elseif ($page_id="147")
         echo "<div class="bilde3"></div>";
       else
         echo "<div class="bilde4"></div>!";
       ?>
       ```
   
 *  Thread Starter [aslamp](https://wordpress.org/support/users/aslamp/)
 * (@aslamp)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/image-and-if-function/#post-1407599)
 * After alot of php reading i made this code and it worked 🙂
    So if anyone else
   have the same proble just use this : <?php if(is_page(‘148’)) echo ‘<div class
   =”bilde2″></div>’; elseif(is_page(’18’)): echo ‘<div class=”bilde3″></div>’; 
   else: echo ‘<div class=”bilde4″></div>’; endif;
 * ?>

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

The topic ‘Image and IF function’ is closed to new replies.

## Tags

 * [if](https://wordpress.org/support/topic-tag/if/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 4 replies
 * 2 participants
 * Last reply from: [aslamp](https://wordpress.org/support/users/aslamp/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/image-and-if-function/#post-1407599)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
