I added a new custom post type to my WordPress theme but it refuses to show on the homepage. I tried setting
<?php query_posts( array( 'post_type' => array('post', 'reviews') ) );?>
but it doesn’t seem to work, it just loops my normal posts. Any suggestions would be greatly helpful.
Here’s a pastie of my index if anyone wants to see it:
I would avoid the use of query_posts — it forces another database hit. There are plenty of other ways to hook in and change the query before posts are fetches.
pre_get_posts
is one of them.To display multiple post types on the home page (pages and posts in this example):
This would go in your themes’s
functions.php
file or in a plugin.I would try this first:
This will keep the original query, and display every single post (-1 means “all posts”), of every post type. That should help you troubleshooting the issue.