Custom Post Types In The Loop: Using `request` Instead Of `pre_get_posts`

[deprecated permalink=”http://uncommoncontent.com/2012/01/28/add-custom-post-types-to-the-loop”]

I’m currently testing out a new version of my code to include custom post types in The Loop. So far, I haven’t found any functional differences. I’d like to do some things with post type archives and a possible `is_type()` function that would make my life easier when working with theme development, hence the change. I’m also trying out `any` instead of an array of post types.


[[wp-hackers] ‘request’ filter for adding custom post types to blog indexes](http://lists.automattic.com/pipermail/wp-hackers/2010-August/033951.html)

2 thoughts on “Custom Post Types In The Loop: Using `request` Instead Of `pre_get_posts`”

  1. Thanks for this blog and this post. I’m a WP newbie (actually, it’s been too long — Started working with WP 3.0; now on WP 3.2.1 — I’m just an idiot). Trying to support a custom post type (“articles”) in the simplest possible way: same appearance of pages displaying the two post types, merely want disjoint lists of posts of the two types, and distinct archive links. Our WP site is configured to show a static home page (Dashboard > Settings > Reading > “Front page displays” == “A static page”). But adding the above code makes the home page display the default “blog”-type home page instead. I’m wondering if I could add another condition to
    if ( empty( $query[‘preview’] ) && empty( $query[‘feed’] ) ) {
    such as ! is_single() or ! is_page(), but I don’t even know what variable to pass as an argument to these functions. $page ??
    I think I’ll try your other approach, using pre_get_posts(). Or something else….

Leave a Reply