Title: PHP Ifelse not working :(
Last modified: August 20, 2016

---

# PHP Ifelse not working :(

 *  Resolved [derekfreeze](https://wordpress.org/support/users/derekfreeze/)
 * (@derekfreeze)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/php-ifelse-not-working/)
 * I’m working on a tweak for my company. I am trying to make an ifelse statement
   for this code.
 * `title="<?php the_title(); ?>"><?php the_title(); ?>`
 * The ifelse needs to make it so in place of the_title() is static text to display‘
   view this devotional’ if a post is (in_category( ‘Devotions’ ) else display ‘
   View this post’.
 * I am having trouble with it, if anyone could help me it would be greatly appreciated.

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

 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/php-ifelse-not-working/#post-2473635)
 * Replace the **second**:
 * `<?php the_title(); ?>`
 * with:
 *     ```
       <?php
       if (in_category('Devotions')):
           echo "View this devotional";
       else:
           echo "View this post";
       endif; ?>
       ```
   
 * Note: untested – please try on a test install first.
 *  Thread Starter [derekfreeze](https://wordpress.org/support/users/derekfreeze/)
 * (@derekfreeze)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/php-ifelse-not-working/#post-2473656)
 * Thank you so much. Just want i needed. I was doing the exact code, but i was 
   forgetting the : after the ))
 * Thanks so much!!!
 * May God Bless You!
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/php-ifelse-not-working/#post-2473659)
 * My pleasure. 🙂

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

The topic ‘PHP Ifelse not working :(’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/php-ifelse-not-working/#post-2473659)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
