Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

lee mullen
lee mullen
8,281 Points

Custom Homepage Templates in WordPress Quiz

I have tried for the last hour to answer this question and no matter what answer I have given the result is the same "BUMMER" So now I've had enough, I've watched and re-watched the videos and read numerous pages of information to try and get this answer correct and still I have failed so please can some one answer this for me?

Write out a conditional statement that tests if a page is the front page in WordPress

I've tried these answers:

if (is_front_page() )

if(is_front_page() ) ?

is_front_page()

$num_posts = ( is_front_page() ) ? 4 : -1;

all of these are wrong.

Jean Paiva
Jean Paiva
7,128 Points

Try this:

is_front_page();

With the semicolon at the end.

I saw this on WordPress Codex (http://codex.wordpress.org/Function_Reference/is_front_page)

9 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

This will work if you remove the space after if.

if ( is_front_page() )

lee mullen
lee mullen
8,281 Points

Fantastic if( is_front_page() ) worked :D

but why did if (is_front_page() ) not work?

Andrew Shook
Andrew Shook
31,709 Points

I would hazard to guess that it's a bug. Contact treehouse support and let them know.

lee mullen
lee mullen
8,281 Points

Hi Andrew,

Thanks I shall get onto that now.

Andrew Shook
Andrew Shook
31,709 Points

Just for reference, I tried every combination of is_front_page and is_home I could think of and it rejected all of them.

lee mullen
lee mullen
8,281 Points

and guess what the answer to that was lol ??????

Bummer! Unfortunately, that answer is incorrect.

lee mullen
lee mullen
8,281 Points

Jean Paiva Thanks but yet again the man from delmonti he say NO

Jean Paiva
Jean Paiva
7,128 Points

You already tried with php tags?

<?php ?>

lee mullen
lee mullen
8,281 Points

yep ive copied the exact code that they use in the videos using the php and endif tags

Jean Paiva
Jean Paiva
7,128 Points

If you open this core file (query.php)

You will see the statement in usage, line 414

https://core.trac.wordpress.org/browser/tags/4.0.1/src/wp-includes/query.php#L0

I don't know exactly what they are asking on that question, but we are close.

lee mullen
lee mullen
8,281 Points

Thanks Jean Paiva even tho we still haven't got the answer correct you have been a great help but this 1 question is really bugging me even tho i have moved past this part (got enough correct to move on) it will haunt me till i get the answer correct.

Andrew Shook
Andrew Shook
31,709 Points

Can you post a direct link to the challenge?

lee mullen
lee mullen
8,281 Points

Thank god so its not me going mad then or being dumb lol

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Wrap is_front_page inside an if statement and it should work. You can't just use the call without the if statement and have it work ;)

lee mullen
lee mullen
8,281 Points

if(is_front_page() ) {}

and

if(is_front_page() ) {};

Neither work :(