Title: WordPress Conditions
Last modified: August 31, 2016

---

# WordPress Conditions

 *  [Fabloria](https://wordpress.org/support/users/fabloria/)
 * (@fabloria)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/wordpress-conditions/)
 * Hi
 * I´m not very good with coding so I was hoping someone could help me with this:
   
   I’m looking to add a condition to an image, so if I´m at pages with ids 1, 2,
   3, the image link will be [http://www.example.com/test](http://www.example.com/test)
   otherwise the image link will be [http://www.example.com](http://www.example.com)
 * How can I do this?

Viewing 1 replies (of 1 total)

 *  [C W (VYSO)](https://wordpress.org/support/users/cyril-washbrook/)
 * (@cyril-washbrook)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/wordpress-conditions/#post-6936524)
 * At the relevant point in the theme template, something like this:
 *     ```
       <?php
          if( is_page( array( 1, 2, 3 ) ) ) :
             $img_link = "http://www.example.com/test";
          else :
             $img_link = "http://www.example.com";
          endif;
       ?>
       <a href="<?php echo $img_link; ?>"><img src="hello-world.png" width="400" height="400" alt="Hello world" /></a>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘WordPress Conditions’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [C W (VYSO)](https://wordpress.org/support/users/cyril-washbrook/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/wordpress-conditions/#post-6936524)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
