Title: Php if within if problem (is_home function)
Last modified: August 20, 2016

---

# Php if within if problem (is_home function)

 *  Resolved [ggg377](https://wordpress.org/support/users/ggg377/)
 * (@ggg377)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/)
 * Hi, I’m trying to figure out how to include a custom php string within WordPress’s
   is_home() function. The catch is I want it to be surrounded by a div.
 * My current setup looks something like this:
 *     ```
       <?php if ( is_home() ) {
       <div class="unimportant"> if(function_exists('tptn_show_daily_pop_posts')) tptn_show_daily_pop_posts(); </div>
       }
       ?>
       ```
   
 * but it throws a syntax error. The custom string looks this unmodified:
 *     ```
       <?php if(function_exists('tptn_show_daily_pop_posts')) tptn_show_daily_pop_posts(); ?>.
       ```
   
 * It should look something like this: if is_home: div—tptn_show_daily_pop_posts—/
   div. The solution should be a rather quick one, but I’m having issues with syntax.
 * Thanks in advance for your replies.

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

 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514391)
 * Try this…
 *     ```
       <?php 
   
       if ( is_home() ) {
           ?><div class="unimportant"><?php
               if(function_exists('tptn_show_daily_pop_posts'))
                   tptn_show_daily_pop_posts();
           ?></div><?php
       }
   
       ?>
       ```
   
 * It’s untested.. but assuming your functions are correct… it should work.
 *  Thread Starter [ggg377](https://wordpress.org/support/users/ggg377/)
 * (@ggg377)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514427)
 * Hey Josh, thanks for answering.
 * For some reason the is_home functionality doesn’t work. The tptn_show_daily_pop_posts
   function shows up on all pages.
 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514435)
 * Try using “is_front_page” instead of “is_home”.
 * Here is a list of all WP conditionals:
    [http://codex.wordpress.org/Conditional_Tags](http://codex.wordpress.org/Conditional_Tags)
 *  Thread Starter [ggg377](https://wordpress.org/support/users/ggg377/)
 * (@ggg377)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514439)
 * It still doesn’t work. I’m pretty sure I’m not mixing something up. A previous
   similar is_home function I had in place of this worked.
 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514441)
 * Okay, so let’s try..
 *     ```
       if ( is_home() ) {
           echo 'Testing...';
       }
       ```
   
 * Does that work correctly?
 *  Thread Starter [ggg377](https://wordpress.org/support/users/ggg377/)
 * (@ggg377)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514442)
 * Ah I’m sorry Josh. It was my mistake. I forgot to put another part of a code 
   I didn’t post about here within the tags so I was surprised when it showed up
   everywhere. I got it now.
 * Thanks a lot for your time 🙂
 *  [Josh](https://wordpress.org/support/users/josh401/)
 * (@josh401)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514474)
 * Excellent 🙂
 * My pleasure! Very glad you got it working!!

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

The topic ‘Php if within if problem (is_home function)’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [Josh](https://wordpress.org/support/users/josh401/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/php-within-php-problem-is_home-function/#post-3514474)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
