WordPress Custom Type loop

With the upcoming version of WordPress 3 (available in beta as of today) here is a tip of how to pull the custom types in the loop once you have created them.

PHP:
    <h3>Recent News</h3>
    <ul>
    < ?php
        $recentPosts = new WP_Query();
        $recentPosts->query($query_string . '&post_type=news');
    ?>
    < ?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
        <li><a href="<?php the_permalink() ?>" rel="bookmark">< ?php the_title(); ?></a></li>
    < ?php endwhile; ?>
    </ul>

In the example above I have created a "News" custom type and now I am adding them to the page with a custom loop.

Leave a Reply