By default, WordPress only displays the loop of contents from the blog post type. If we add custom post types, it doesn’t get automatically displayed on home page. To do so, we have to manually add the php snippet below to the Home page. To explain it simply, we’re adding a new loop to display the custom post type.
In this example, we will add a custom post type called “movie” to our second loop.
<?php query_posts( 'post_type=movie&posts_per_page=3'); ?> <?php if (have_posts()) : ?><table><tr> <?php while (have_posts()) : the_post(); ?> <h4><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h4><br /> <?php the_excerpt(); ?> <?php endwhile; ?> <?php endif; ?>
The code above lets you display the 3 most recent posts you have under a custom post type called ‘movie’. Easy stuff eh?
Related posts:
- Create Custom Post Types and Taxonomies on WordPress Hello friends! You don’t know but I’m working on a...
- How To Create an Artist Database on WordPress Ever thought of creating something like IMDB or STLyrics or Yahoo...
- Displaying Post Thumbnail on WordPress Home Page Here’s how to show post thumbnails on the home page...
Thanks for your great tips. It’s so simple but really help me to show my custom post type list in home page.