WordPress 3.0 will allow you to create custom post types, so what about being able to list those custom types on your blog homepage? This very useful piece of code will show you how you can do it.
The following code have to be pasted in your functions.php file. Once the file will be saved, it will work.
As you can see in the code, the post, page, album, movie, quote, and attachment types will be displayed. Modify that line to fit your own needs.
add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() ) $query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'attachment' ) ); return $query; }
Please note that custom post types are not available by default on WordPress 2.9. You could have a look there if you’re looking to implement that functionnality right now.
Credits goes to Justin Tadlock for this handy recipe!
By the way, if you’re looking to advertise on CodeRevolution, I got a free spot so be quick! Click here to buy.
