Title: Difficult if/else statement
Last modified: August 19, 2016

---

# Difficult if/else statement

 *  [David Cameron Law](https://wordpress.org/support/users/seo-dave/)
 * (@seo-dave)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/difficult-ifelse-statement/)
 * Basically what I want is to use an if/else statement where
 * If comment_author_url NOT empty use this code else use some other code
 * In this way if a commenters added a URl I’ll use it with some associated code,
   if not I’ll show the author name (comment_author) with associated code.
 * I don’t want to use the comment_author_link function as I want to create the 
   comment links using a form (so a form button is the link) so search engines won’t
   treat them as links (trying to get rid of nofollow links for SEO reasons).
 * Got it almost working here [http://www.free-funny-jokes.com/yo-mamas-so-dumb.html](http://www.free-funny-jokes.com/yo-mamas-so-dumb.html)
   minus the if not empty bit, so the form button link shows for all commenters 
   with the URL part empty when the author doesn’t add a URL.
 * Not been able to figure out the not empty part.
 * Thanks
 * David Law

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/difficult-ifelse-statement/#post-1167874)
 * Try using [get_comment_author_url](http://codex.wordpress.org/Template_Tags/get_comment_author_url).
 * `if (empty(get_comment_author_url()) || get_comment_author_url() == 'http://')[
   show form button]`
 *  Thread Starter [David Cameron Law](https://wordpress.org/support/users/seo-dave/)
 * (@seo-dave)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/difficult-ifelse-statement/#post-1167901)
 * Thanks Esmi, couldn’t get the above to work, but it made me think of a solution,
   ended up using this code:
 *     ```
       <?php if($comment->comment_author_url != "") : ?>
   
       Code for when there is a URL
   
       <?php else : ?>
   
       Code for when no URL.
   
       <?php endif; ?>
       ```
   
 * Works exactly how I want it, added a little css to make the button look more 
   like a link and only difference is when I hover over the button link no colour
   change (will fix that with css later).
 * Example at: [http://www.free-funny-jokes.com/chuck-norris-jokes.html#comment-37410](http://www.free-funny-jokes.com/chuck-norris-jokes.html#comment-37410)
   where the ‘Joker’ comment is a form/button link, all the other comments didn’t
   have links as disabled the ability to add them to the theme ages ago.
 * Can renable commenters URLs now and not have to worry about loosing link benefit
   since Google fecked up how it treats the nofollow attribute!
 * David Law

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

The topic ‘Difficult if/else statement’ is closed to new replies.

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [David Cameron Law](https://wordpress.org/support/users/seo-dave/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/difficult-ifelse-statement/#post-1167901)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
