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 From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Static Page Template with Sidebar

syntax error with php if statement...

I'm trying to get run an if statement against the page title so that my sidebar changes depending on the title of the page.

what am I doing wrong.

here's my code.

<?php if ( get_the_title() == 'Job Classes' ); ?>

    <div class="col-xs-12 col-md-4">
        <ul class="nav nav-pills nav-stacked">
            <li role="presentation" class="active"><a href="#classes">Job Classes</a></li>
            <li role="presentation"><a href="#aba">ABA</a></li>
        </ul>
    </div>


<?php else : ?> 

    <?php if ( dynamic_sidebar( 'archive' ) ); ?>

<?php endif; ?>     

2 Answers

I put a semi colon instead of a colon on line 1.

you have to enclose your if code and else code in {}

Thanks for the reply. But it ended up being because I have a semi colon instead of a colon on my line 1.

It must be a Wordpress thing. I have not seen that syntax before.

Ted Sumner: not a Wordpress thing, it's pretty standard php syntax; you can define conditionals either with brackets or with colons and "endifs", "endwhiles" etc. Makes for less cumbersome integration with HTML, for one thing. http://php.net/manual/en/control-structures.alternative-syntax.php