Custom Post Type – archive working – single is not

After some time banging my head against the wall, I found the solution.
I used https://underscores.me/ as a starter for my theme. One function sets the main query, where one can add custom post types as well. So if anybody encounters the same problem, be aware of the hook “pre_get_posts”.

function gp_add_cpt_post_names_to_main_query( $query ) {
    // Bail if this is not the main query.
    if ( ! $query->is_main_query() ) {
        return;
    }

    // Bail if this query doesn't match our very specific rewrite rule.
    if ( ! isset( $query->query['page'] ) ) {
        return;
    }

    // Bail if we're not querying based on the post name.
    if ( empty( $query->query['name'] ) ) {
        return;
    }
    // Add CPT to the list of post types WP will include when it queries based on the post name.
    $query->set( 'post_type', array( 'post', 'page', 'regie' ) );
}
add_action( 'pre_get_posts', 'gp_add_cpt_post_names_to_main_query' );

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino