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

Building a WordPress Theme Error

I'm working on the How to Build a WordPress theme course and I must have a syntax error that I don't see. I am trying to put 3 featured blog posts on my landing page.

```<?php get_header(); ?>

<div class="page-wrap"> <p>This is front-page.php</p> </div>

<?php if (have_posts() ) : while ($the_query->have_posts() ) :$the_query->the_post(); ?>

<section id="featuredBlogPosts"> <div class="page-wrap"> <h3>Business Oriented Blog Posts</h3>

    <?php 
        $args = array(
            'post-type' => 'post',
            'category_name' => 'featured',
            'posts_per_page' => 3
        );

        $the_query = new WP_Query('$args');
    ?>

    <?php if (have_posts() ) : while ($the_query->have_posts() ) :$the_query->the_post(); ?>

    <div class="threecolumn">
        <?php get_template_part('content', 'post'); ?>
    </div>

    <?php endwhile; endif; ?>
</div>

</section>

<?php get_footer(); ?>```

2 Answers

You're missing a space between the colon and $the_query in your loop statement:

:$the_query->the_post();

Should be

: $the_query->the_post();

I found it. I had <?php if (have_posts() ) : while ($the_query->have_posts() ) :$the_query->the_post(); ?> twice on the page.