[deprecated permalink="http://uncommoncontent.com/2012/01/28/add-custom-post-types-to-the-loop"]
I wrote this function to allow me to use custom post types in my blog without having to fine-tune each template for their inclusion. It checks the query to see if post_type is set; if it is not set (as it would be on a specific post type’s archive page), it includes all public post types.
- 26 August 2010: Changed
! is_page() && ! is_single()to! is_singular().
Beautifully perfect, just what the doctor ordered.
Thanks J.M.
You, my friend, are a master. I have been searching for days on end… I was trying to include a custom post type categorie in the category.php-view, but these aren’t queried by default. This does the trick! Thanks a million!
Just a note… after activating this function, custom menus stopped working on 404 not found pages. They worked elsewhere, just not on 404 pages. Strange, eh?
I’ve further refined this function here; since 404 pages are “singular”, I’ve included them in the list of exceptions.
Thank you SO much for this. Been scratching my head all night trying to achieve this. And you nailed it – it solved all my issues.