[CPT] Archive & category pages
-
Hi all,
I got a custom post type and I created multiple categories for them.
The problem is that I’m able to create category pages for each category but not an archive for all posts in my custom post type.I think it got something to do with the rewriting of the slug.
Below I added the rewrite, because normally custom post types creates an url without the category in it:
'rewrite' => array('slug' => 'recept/%category%','with_front' => false),Below the function:
function wpa_course_post_link( $post_link, $id = 0 ){ $post = get_post($id); if ( is_object( $post ) ){ $terms = wp_get_object_terms( $post->ID, 'category' ); if( $terms ){ return str_replace( '%category%' , $terms[0]->slug , $post_link ); } else { return str_replace( '%category%' , "" ); } } return $post_link;Now my custom post type is recept and I’m not able to create a archive page for it. It gives me a 404.
Anybody got an idea what’s going wrong?
Cheers
The topic ‘[CPT] Archive & category pages’ is closed to new replies.