Benutzerdefinierte Taxonomievorlage und URL-Verwechslung

Ich habe einen benutzerdefinierten Beitragstyp namens case_study . Die benutzerdefinierte Taxonomie, die damit direkt in Beziehung steht, heißt case_study_categories . Mein Code ist unten.

Ich habe eine benutzerdefinierte Taxonomieseite namens taxonomy-case_study_categories.php . Ich kann jedoch nicht auf die Seite zugreifen, wenn ich etwas wie example.com/case_study_categories beginne.

Ich habe die Rewrite-Regeln auch als letzte function. Irgendwelche Gedanken?

 function cpt_case_study() { $labels = array( 'name' => _x( 'Case Studies', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Case Study', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Case Study', 'text_domain' ), 'name_admin_bar' => __( 'Case Study', 'text_domain' ), 'archives' => __( 'Case Study Archives', 'text_domain' ), 'parent_item_colon' => __( 'Parent Case Study:', 'text_domain' ), 'all_items' => __( 'All Case Studies', 'text_domain' ), 'add_new_item' => __( 'Add New Case Study', 'text_domain' ), 'add_new' => __( 'Add New', 'text_domain' ), 'new_item' => __( 'New Case Study', 'text_domain' ), 'edit_item' => __( 'Edit Case Study', 'text_domain' ), 'update_item' => __( 'Update Case Study', 'text_domain' ), 'view_item' => __( 'View Case Study', 'text_domain' ), 'search_items' => __( 'Search Case Studies', 'text_domain' ), 'not_found' => __( 'Not found', 'text_domain' ), 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ), 'featured_image' => __( 'Featured Image', 'text_domain' ), 'set_featured_image' => __( 'Set featured image', 'text_domain' ), 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ), 'use_featured_image' => __( 'Use as featured image', 'text_domain' ), 'insert_into_item' => __( 'Insert into Case Study', 'text_domain' ), 'uploaded_to_this_item' => __( 'Uploaded to this Case Study', 'text_domain' ), 'items_list' => __( 'Case Study list', 'text_domain' ), 'items_list_navigation' => __( 'Case Study list navigation', 'text_domain' ), 'filter_items_list' => __( 'Filter Case Study list', 'text_domain' ), ); $args = array( 'label' => __( 'Case Study', 'text_domain' ), 'description' => __( 'Case Studies', 'text_domain' ), 'labels' => $labels, 'supports' => array( ), 'taxonomies' => array( 'case_study_categories' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 25, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'case_study', $args ); } add_action( 'init', 'cpt_case_study', 0 ); function tax_case_study() { register_taxonomy( 'case_study_categories', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). 'case_study', //post type name array( 'hierarchical' => true, 'label' => 'Case Study Categories', //Display name 'query_var' => true, 'rewrite' => array( 'slug' => 'case_study/%case_studies%', // This controls the base slug that will display before each term 'with_front' => false // Don't display the category base before ) ) ); } add_action( 'init', 'tax_case_study'); function filter_post_type_link($link, $post){ if ($post->post_type != 'case_study') return $link; if ($cats = get_the_terms($post->ID, 'case_study_categories')) $link = str_replace('%case_study_categories%', array_pop($cats)->slug, $link); return $link; } add_filter('post_type_link', 'filter_post_type_link', 10, 2); 

UPDATE: Wenn ich die Permalinks auf plain (? Case_study_categories = xyz) setze, funktioniert das. Wenn ich jedoch meine Permalinks auf /%category%/%postname%/ , funktioniert das nicht. Ich bekomme 404.

Solutions Collecting From Web of "Benutzerdefinierte Taxonomievorlage und URL-Verwechslung"