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

Dave Six
Dave Six
8,366 Points

Display custom post type thumbnails

I'm trying to display thumbnails of a custom post type only(!). My current code is working, but it also shows thumbnails of other post types.

Here's the code, displaying the logos at the moment:

<div id="logos">
        <div class="inner-logos">

            <?php
            $loop = new WP_Query(array('post_type' => array('logos') & 'post_status=publish'));
            while ($loop->have_posts()) : $loop->the_post();
                ?>
                <div class="logo"><?php echo the_post_thumbnail('medium'); ?></div>
            <?php endwhile;
            ?>
        </div>

    </div>

What options do I have to select the thumbnails of the custom post type?

karennh
karennh
4,925 Points

Try this:

$loop = new WP_Query(array('post_type' => 'logos', 'post_status' => 'publish'));