Title: php syntax help
Last modified: August 19, 2016

---

# php syntax help

 *  Resolved [heidipj](https://wordpress.org/support/users/heidipj/)
 * (@heidipj)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/php-syntax-help/)
 * Hi there,
 * I am trying to do an if else in php but it’s not working… Can someone take a 
   quick look and tell me what I am doing wrong? What I’m trying to do: if post 
   ID is not equal to 27 (id of homepage) then show post title.
 *     ```
       <?php if ( the_ID()!=27 ) { ?>
       <h2><?php the_title(); ?></h2>
       <?php } ?>
       ```
   
 * any help would be much appreciated.

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

 *  [leadandfollow](https://wordpress.org/support/users/leadandfollow/)
 * (@leadandfollow)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/php-syntax-help/#post-886573)
 * Probably you need to echo the title so that it actually prints:
 * `<?php echo the_title(); ?>`
 *  Thread Starter [heidipj](https://wordpress.org/support/users/heidipj/)
 * (@heidipj)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/php-syntax-help/#post-886576)
 * yeh i tried that. Funnily enough with my code there it prints out the post id
   first and then the post title regardless of the if else statement.
 *  [leadandfollow](https://wordpress.org/support/users/leadandfollow/)
 * (@leadandfollow)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/php-syntax-help/#post-886622)
 * Actually, sorry, these are template tags and do not need to be echoed. Probably
   you should use functions that are not template tags if you do not want it to 
   be printed.
 * [http://codex.wordpress.org/Function_Reference/get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta)
 *  Thread Starter [heidipj](https://wordpress.org/support/users/heidipj/)
 * (@heidipj)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/php-syntax-help/#post-886625)
 * Thanks leadandfollow – not exactly what I was looking for but I hunted around
   a bit more and found this page which was helpful [http://codex.wordpress.org/Conditional_Tags#The_Front_Page](http://codex.wordpress.org/Conditional_Tags#The_Front_Page)
 * The code which worked for me eventually was:
 *     ```
       <?php if( !is_front_page() ){  ?>
       <h2><?php the_title(); ?></h2>
       <?php } ?>
       ```
   

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

The topic ‘php syntax help’ is closed to new replies.

## Tags

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

 * 4 replies
 * 2 participants
 * Last reply from: [heidipj](https://wordpress.org/support/users/heidipj/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/php-syntax-help/#post-886625)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
