custom post types and archive pages
-
Hey. I got a problem when using custom post types. I described it here before:
https://stackoverflow.com/questions/4951537/wordpress-custom-post-type-categories
I register this custom post type like this:
register_post_type("lifestream", array( 'label' => 'Lifestream', 'public' => true, 'hierarchical' => true, 'menu_position' => 5, 'supports' => array('title','editor','author','thumbnail','comments','custom-fields'), 'taxonomies' => array('category','post_tag'), 'query_var' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'caller_get_posts' => 1 )); register_taxonomy_for_object_type('category', 'lifestream'); register_taxonomy_for_object_type('post_tag', 'lifestream');
In the theme (the loop template) I like to combine posts and my custom post type, for that I am using query_posts() with these parameters:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => array('post', 'lifestream'), 'paged' => $paged, 'cat' => $wp_query->get('cat'), 'tag' => $wp_query->get('tag'), 'year' => $wp_query->get('year'), 'monthnum' => $wp_query->get('monthnum'), 'post_status' => 'publish', 'showposts' => 3 ); query_posts($args); # the loop while ( have_posts() ) : the_post(); # markup endwhile; if($wp_query->max_num_pages > 1): # next_posts_link / previous_posts_link endif; wp_reset_query();
This is working so far. But, I got problems with the category and tags pages. If I call the frontpage everything is fine and I can paginate through the pages getting the correct results.
And, if I call a paged URL, e.g. /category/mycat/page/2 a 404 is thrown. But there definitly should be posts. No matter if there are custom type posts or normale posts in the category. I suppose that my parameters for query_posts() aren′t correct, but don′t know …
Do you have any Idea what to do? Thanks a lot!
- The topic ‘custom post types and archive pages’ is closed to new replies.