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 triallee mullen
8,281 PointsCustom 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.
9 Answers
Zac Gordon
Treehouse Guest TeacherThis will work if you remove the space after if.
if ( is_front_page() )
lee mullen
8,281 PointsFantastic if( is_front_page() ) worked :D
but why did if (is_front_page() ) not work?
Andrew Shook
31,709 PointsI would hazard to guess that it's a bug. Contact treehouse support and let them know.
lee mullen
8,281 PointsHi Andrew,
Thanks I shall get onto that now.
Andrew Shook
31,709 PointsJust 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
8,281 Pointsand guess what the answer to that was lol ??????
Bummer! Unfortunately, that answer is incorrect.
lee mullen
8,281 PointsJean Paiva Thanks but yet again the man from delmonti he say NO
Jean Paiva
7,128 PointsYou already tried with php tags?
<?php ?>
lee mullen
8,281 Pointsyep ive copied the exact code that they use in the videos using the php and endif tags
Jean Paiva
7,128 PointsIf 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
8,281 PointsThanks 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
31,709 PointsCan you post a direct link to the challenge?
lee mullen
8,281 PointsHi Andrew,
Thanks for taking a look!
lee mullen
8,281 PointsThank god so its not me going mad then or being dumb lol
Zac Gordon
Treehouse Guest TeacherWrap 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
8,281 Pointsif(is_front_page() ) {}
and
if(is_front_page() ) {};
Neither work :(
Jean Paiva
7,128 PointsJean Paiva
7,128 PointsTry 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)