Title: Whats wrong with this PHP code?
Last modified: August 20, 2016

---

# Whats wrong with this PHP code?

 *  [freebieshark](https://wordpress.org/support/users/freebieshark/)
 * (@freebieshark)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-php-code/)
 * Hello! I am trying to paste this code in custom_functions.php, but I keep getting
   an error. I then have to remove the code through my cPanel. One thing to note
   is that I am placing this code at the very end of custom_functions.php .. Any
   help is appreciated!
 *     ```
       function expiredpost(){
         if(in_category('expired')){
         ?>
           <div class="expired_img">
               <? echo "<img src='http://www.freebieshark.com/wp-content/uploads/2012/02/expired2.png'>"; ?>
            </div> <?
        }
       }
       add_action('thesis_hook_before_post', 'expiredpost');
       ```
   

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

 *  [Jonas Grumby](https://wordpress.org/support/users/ss_minnow/)
 * (@ss_minnow)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-php-code/#post-2606530)
 * I don’t think `if(in_category())` is valid code for a conditional tag.
 * I’m sure that `<? echo` is not valid code.
 *     ```
       <?
        }
       }
       ```
   
 * is also not valid code.
 *  [fonglh](https://wordpress.org/support/users/fonglh/)
 * (@fonglh)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-php-code/#post-2606540)
 * [http://codex.wordpress.org/Function_Reference/in_category](http://codex.wordpress.org/Function_Reference/in_category)
 *  Thread Starter [freebieshark](https://wordpress.org/support/users/freebieshark/)
 * (@freebieshark)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-php-code/#post-2606552)
 * Thanks for the replies.. I am not good with PHP at all.. Does anybody know what
   exactly will fix this code?
 *  [fonglh](https://wordpress.org/support/users/fonglh/)
 * (@fonglh)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-php-code/#post-2606648)
 * Is there a closing PHP tag before the code you’re adding?

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

The topic ‘Whats wrong with this PHP code?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [fonglh](https://wordpress.org/support/users/fonglh/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-php-code/#post-2606648)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
