Custom post type category navigation
-
Hi!
I’m going crazy on this one! I’ve searched google and forums for days looking for a solution to get this up an running…
My scenario is as follows:
I’ve created a custom post type with three custom taxonomies attached to it.1 of these are a hierarchical (category) and the other two are tags.
I want the hierarchical one to act like the default post categories does in the menu.As so:
Cat 1 (https://localhost/aoc/tavlingar/alla/)
– Sub cat 1 (https://localhost/aoc/tavlingar/tavlingar-mtb/)
– Sub cat 2 (https://localhost/aoc/tavlingar/tavlingar-lvg/)
and so on.
The permalinks works just as I want them, but the content just shows up in archive.php and doesn’t matter which sub-cat I’m in.I can’t get it to pick up the archive-aoc_tavlingar.php either, it just fall backs to archive.php
This is what my functions.php looks like.
add_action( 'init', 'create_aoc_tavlingar_cpt' ); function create_aoc_tavlingar_cpt() { register_post_type( 'aoc_tavlingar', array( 'labels' => array( 'name' => __( 'T?vlingar' ), 'singular_name' => __( 'T?vling' ), 'add_new' => __('L?gg till ny'), 'add_new_item' => __('L?gg till ny t?vling'), 'edit' => __('?ndra'), 'edit_item' => __('?ndra t?vling'), 'new_item' => __('Ny t?vling'), 'view' => __('Visa t?vling'), 'view_item' => __('Visa t?vling'), 'search_items' => __('S?k t?vling'), 'not_found' => __('Ingen t?vling hittades'), 'not_found_in_trash' => __('Ingen t?vling i papperskorgen') ), 'public' => true, 'menu_position' => 5, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title','custom-fields','thumbnail'), 'rewrite' => array('slug' =>'tavling','with_front' => true), 'has_archive' => true, 'taxonomies' => true ) ); } add_action( 'init', 'taxonomy_aoc_tavlingar'); function taxonomy_aoc_tavlingar() { register_taxonomy( 'aoc_tavlingar_gren', 'aoc_tavlingar', array( 'hierarchical' =>true, 'label' => 'Gren', 'query_var' => true, 'rewrite' => array('slug' =>'tavlingar','with_front' => true), ) ); } add_action( 'init', 'taxonomy_aoc_tavlingar_tag_typ'); function taxonomy_aoc_tavlingar_tag_typ() { register_taxonomy( 'aoc_tavlingar_typ', 'aoc_tavlingar', array( 'hierarchical' =>false, 'label' => 'Typ av lopp', 'query_var' => true, 'rewrite' => array('slug' =>'tavlings_typ','with_front' => true), ) ); } add_action( 'init', 'taxonomy_aoc_tavlingar_tag_misc', 0); function taxonomy_aoc_tavlingar_tag_misc() { register_taxonomy( 'aoc_tavlingar_misc', 'aoc_tavlingar', array( 'hierarchical' =>false, 'label' => '?vrigt', 'query_var' => true, 'rewrite' => array('slug' =>'tavlingar_ovrigt','with_front' => true), ) ); }
ANY help is appreciated!
- The topic ‘Custom post type category navigation’ is closed to new replies.