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

Displaying widget area in Static Front Page only - How to write necessary conditional statement

Hi there, Following from the Wordpress theme tutorials, am trying to widgetize the footer area of my own static Wordpress front page.

I only want the widget area to appear on the front page. I can get the widgets to display across all pages indiscriminately, but do not know how to write the correct conditional statement to only display on the front page.

this is the syntax I am using, which to me seemed logical enough:

<?php if ( is_page_template('front-page.php') ) { ?>

<div>
            <?php dynamic_sidebar( 'home-page-footer-area' ); ?>

                </div>

<?php } ?>

It isn't working however.

Have tried umpteen other permutations too.

'is_front_page' doesn't select my front page within a conditional statement either, I think because I have a loop set up in this page template just to pull in the latest sticky post.

Can anyone advise me on where I am going wrong?

1 Answer

Just found answer almost immediately after posting. On the off-chance anyone gets stuck with similar issue, here's the code that works:

<?php wp_reset_query() ?>

<?php if ( is_front_page() ) :?>


<div>
            <?php dynamic_sidebar( 'home-page-footer-area' ); ?>

                </div>

<?php endif; ?>