So I'm really at my wits end here. I'm trying to get the single page working for my custom post type. I've done it several times now, but right now its just not working (404 - not found). I hope I just overlooked something...
Another weird thing is, the archive page for my custom post type is working. Enough talk, here is some code.
in functions.php
function register_my_post_type() {
$labels = [
"name" => esc_html__( "regies", "my-text-domain" ),
"singular_name" => esc_html__( "Regie + Buch", "my-text-domain" ),
"menu_name" => esc_html__( "Regie und Buch", "my-text-domain" ),
"all_items" => esc_html__( "Alle Regisseure", "my-text-domain" ),
"add_new" => esc_html__( "Neuer Regisseur", "my-text-domain" ),
];
$args = [
"label" => esc_html__( "regies", "my-text-domain" ),
"labels" => $labels,
"description" => "Regie und Buch",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "regie",
"rest_controller_class" => "WP_REST_Posts_Controller",
"rest_namespace" => "wp/v2",
"has_archive" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"delete_with_user" => false,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"can_export" => false,
"rewrite" => [ "slug" => "regisseur", "with_front" => true ],
"query_var" => true,
"supports" => [ "title" ],
"taxonomies" => [ "category", "post_tag" ],
"show_in_graphql" => false,
];
register_post_type( "regie", $args );
}
add_action('init', 'register_my_post_type');
archive-regie.php is working as expected. single-regie.php isn't. (404)
What I'm wondering about as well, even if my custom single page is not working. Why is my themes/single.php not doing anything?
I've resaved the permalinks. Either via saving it "plain" and then setting the "real" permalinks or just saving it, done that at least 20 times now. Directly flushing the rewrite rules via code is also not working.
I've deleted and let Wordpress handle the creation of .htaccess.
Even changing the slug to not be the same as the registered custom post type name, didn't help.
I've multiple custom post types working on this exact site. I even copied these register_post_type snippets and changed it accordingly. To no avail.
Hope you can help me.