Custom Post Type – only ‘Plain’-Permalinks work

Heyo everyone,

I’ve a problem with permalinks to custom post types that I couldn’t find a solution for here or elsewhere.

For a friend’s site I created a custom post type which in general works fine. But when I want to change the permalink structure to anything but the plain syntax, links to posts of the custom post type return a 404. It doesn’t matter which structure, none of them work.
All the other links continue to work with these other permalink structures (even Jetpack custom post types such as portfolio or testimonials). I tried all the suggestions I found on other topics (for example the basic resaving of the permalink settings with switching, disabling plugins, updating htaccess, etc.) and since pretty permalinks work for all other things, I can’t be a server side issue, can it?

Does anyone have an idea what could be the cause of it? Or point me in the right direction (maybe I’ve overlooked the solution in the forums here)?

Thank you!

This is how setup the post type in functions.php :

add_action( 'init', 'create_portfolio_category' );

function create_project_category() {
register_post_type( 'project', array(
  'labels' => array(
    'name' => 'Projects',
    'singular_name' => 'Project',
  'description' => 'Projects',
  'public' => true,
  'menu_position' => 20,
  'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail', 'revisions', 'tags' ),
  'taxonomies' => array( 'project-type' ),
  'has_archive' => true,
  'show_in_rest' => true,
  'publicly_queryable' => true,
  'posts_per_page' => 50

add_action( 'init', 'create_project_taxonomies', 0 );

function create_project_taxonomies() {
            'labels' => array(
                'name' => 'Project Types',
                'add_new_item' => 'Add New Project Type',
                'new_item_name' => "Add New Project Type Item"
            'rewrite' => array( 'slug' => 'project', 'with_front' => true ),
            'show_ui' => true,
            'show_tagcloud' => false,
            'hierarchical' => true,
            'show_in_rest' => true

Source link