Built in Categories with Custom Post Types

How to do that is covered in detail in this post on adding a new custom post type.

However, view by category doesn’t work by default with custom post types. This is because the query doesn’t cater for it, thus I had to override category.php and modify the query.

Copy category.php from the twenty ten theme and paste it in my own theme folder. Add the following code before the loop is called.

global $wp_query;
$args = array_merge($wp_query>query,array('post_type'=>array('post','newsletter'),'paged'=>get_query_var('paged')));

This file has also been modified the call the custom loop for newsletters because that post type will have some extra meta data for display.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s