Custom Post Type Taxonomy Archive
-
I have compiled my own WordPress block theme and work with custom post types for my projects, and everything works wonderfully, but I want to build a separate archive page for each category. I have already created a template for this under “Design -> Website Editor -> Templates -> Add Template -> Category Archive -> ‘the correct category'”. However, the template for “all archives” is always output when I go to the category page of the desired category.
What could be the reason for this?
function custom_post_type_projects() { $labels = array( 'name' => 'Projekte', 'singular_name' => 'Projekt', 'menu_name' => 'Projekte', 'add_new' => 'Projekt hinzufügen', 'add_new_item' => 'Projekt hinzufügen', 'edit_item' => 'Projekt bearbeiten', 'new_item' => 'Neues Projekt', 'view_item' => 'Projekt anzeigen', 'search_items' => 'Projekte durchsuchen', 'not_found' => 'Keine Projekte gefunden', 'not_found_in_trash' => 'Keine Projekte im Papierkorb gefunden', ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_rest' => true, 'has_archive' => true, 'publicly_queryable' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'projekte' ), 'capability_type' => 'post', 'menu_icon' => 'dashicons-hammer', // Icon für das Menü 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), ); register_post_type( 'projects', $args ); } add_action( 'init', 'custom_post_type_projects' ); /* ********************************************************************************** */ /* Register Taxonomy */ /* ********************************************************************************** */ function custom_project_type_taxonomy() { $labels = array( 'name' => 'Projekttypen', 'singular_name' => 'Projekttyp', 'search_items' => 'Projekttypen durchsuchen', 'all_items' => 'Alle Projekttypen', 'edit_item' => 'Projekttyp bearbeiten', 'update_item' => 'Projekttyp aktualisieren', 'add_new_item' => 'Neuen Projekttyp hinzufügen', 'new_item_name' => 'Neuer Projekttyp', 'menu_name' => 'Projekttypen', ); $args = array( 'hierarchical' => true, // Wenn true, dann wie Kategorien, ansonsten wie Schlagworte 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_rest' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'projekttyp' ), ); register_taxonomy( 'projekttyp', array( 'projects' ), $args ); } add_action( 'init', 'custom_project_type_taxonomy' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Post Type Taxonomy Archive’ is closed to new replies.