Title: Help with php
Last modified: August 19, 2016

---

# Help with php

 *  [oldmankit](https://wordpress.org/support/users/oldmankit/)
 * (@oldmankit)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/)
 * Hello,
 * I don’t really know php, I just work with what I can from others, copying and
   pasting and slowly understanding things. I have got this far with a link:
 *     ```
       <a href="<?php echo $image->imageURL ?>" title="<h7><?php echo $image->alttext ?></h7><h8>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo $image->description ?></h8>" <?php echo $image->thumbcode ?> >
       				<?php if ( !$image->hidden ) { ?>
       				<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
       				<?php } ?>
       			</a>
       ```
   
 * (The reason I have h7 etc. inside a title is that the title is used by a script–
   shutter. It’s for making a photo gallery.)
 * It’s doing everything nicely, unless $image->description is empty. Then I get
   alttext followed by |. If the description is empty, I don’t want the | to display.
 * I guess this is pretty easy to do, if you know php? Something to do with ‘if’?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950061)
 * There’s no such tag as H7 in HTML.
 *  Thread Starter [oldmankit](https://wordpress.org/support/users/oldmankit/)
 * (@oldmankit)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950112)
 * > There’s no such tag as H7 in HTML.
 * Erm, really? Ok, well I’ll change them to h5 and h6. Actually, the code didn’t
   validate, so I changed the ‘<‘ etc. to the html code. It validates fine now.
 * I’d still like help making the little php ‘if’ bit. I only want `[code]  |  <?
   php echo $image->description ?>[/code]`
    if $image->description is _not_ empty.
 *  Thread Starter [oldmankit](https://wordpress.org/support/users/oldmankit/)
 * (@oldmankit)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950161)
 * Will this be difficult? To reiterate:
 * If the the description field is empty, I want to echo nothing. If it is not empty,
   I want to echo something. How do I do that with php?
 * Thanks to anyone that can help me here… 🙂
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950162)
 *     ```
       <?php if ( $image->hidden ) :?>
       <a href="<?php echo $image->imageURL; ?>" title="<?php echo $image->alttext; ?> <?php echo $image->descriptio;n ?>" <?php echo $image->thumbcode; ?> ><img title="<?php echo $image->alttext; ?>" alt="<?php echo $image->alttext; ?>" src="<?php echo $image->thumbnailURL; ?>" <?php echo $image->size; ?> /></a>
       <?php endif;?>
       ```
   
 *  Thread Starter [oldmankit](https://wordpress.org/support/users/oldmankit/)
 * (@oldmankit)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950163)
 * Thank you for posting. Forgive me if I have misunderstood.
    You’ve started with`
   $image->hidden`, but I’m not using any hidden images. Hidden images are part 
   of NextGen gallery, for images you don’t want to be displayed, I believe.
 * I will try to explain better.
 * Sometimes `<?php echo $image->description ?>` gives me nothing; there is no description
   for the photograph. If there is no description, I want:
    `<a href="<?php echo
   $image->imageURL ?>" title="<?php echo $image->alttext ?>" <?php echo $image-
   >thumbcode ?> >`
 * But if there IS a description, I want:
    `<a href="<?php echo $image->imageURL?
   >" title="<?php echo $image->alttext ?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo $image-
   >description ?>" <?php echo $image->thumbcode ?> >`
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950170)
 *     ```
       <?php if( $image->description ) :?><a href="<?php echo $image->imageURL ?>" title="<?php echo $image->alttext ?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
       <?php else :?> <a href="<?php echo $image->imageURL ?>" title="<?php echo $image->alttext ?>" <?php echo $image->thumbcode ?> >
       <?php endif;?>
       ```
   
 *  Thread Starter [oldmankit](https://wordpress.org/support/users/oldmankit/)
 * (@oldmankit)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950183)
 * Sorry for the delay in testing this.
 * I’ve copied and pasted as is, and unfortunately it is still inserting the ‘|’,
   even when there is no description.
 * Basically, it is always using the first line, and never what follows `<?php else:?
   >`.

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

The topic ‘Help with php’ is closed to new replies.

## Tags

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

 * 7 replies
 * 2 participants
 * Last reply from: [oldmankit](https://wordpress.org/support/users/oldmankit/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/help-with-php-2/#post-1950183)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
