Wordpress 3.0: Query custom post types
April 22, 2010 by admin · Leave a Comment
In Wordpress 3.0 you can create custom types of post.
Good news for developers, there’s nothing hard or new in the process. Custom post types can be retrieved easily, using the WP_Query object.
The following example will create a custom loop which will get only the albums custom post type.
<pre><ul>
<?php global $wp_query;
$wp_query = new WP_Query("post_type=albums&post_status=publish");
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul></pre>
Related posts: