I created a custom post type 'gruppen' and a custom page templete 'page-gruppen.php'. I want to use 'page-gruppen.php' to show my custom post type content but the custom post type uses always the normal wp template 'page.php'

When i print the slug it gives the last post name and not gruppen.

What is my failure?

this is my post typ:

function gruppen_post_type() {
    $labels = array(
        'name'                  => _x( 'Gruppen', 'Post Type General Name' ),
        'singular_name'         => _x( 'Gruppe', 'Post Type Singular Name' ),
        'menu_name'             => 'Gruppen',
        'name_admin_bar'        => 'Gruppen',
        'archives'              => 'Gruppe Archives',
        'attributes'            => 'Gruppe Attributes',
        'parent_item_colon'     => 'Gruppe parent:',
        'all_items'             => 'All Gruppen',
        'add_new_item'          => 'Neue Gruppe hinzufügen',
        'add_new'               => 'Gruppe hinzufügen',
        'new_item'              => 'Neue Gruppe',
        'edit_item'             => 'Gruppe editieren',
        'update_item'           => 'Gruppe aktualisieren',
        'view_item'             => 'Gruppe anzeigen',
        'view_items'            => 'Gruppen anzeigen',
        'search_items'          => 'Gruppe suchen',
        'not_found'             => 'Not found',
        'not_found_in_trash'    => 'Not found in Trash',
        'featured_image'        => 'Featured Image',
        'set_featured_image'    => 'Set featured image',
        'remove_featured_image' => 'Remove featured image',
        'use_featured_image'    => 'Use as featured image',
        'insert_into_item'      => 'In Gruppe einfügen',
        'uploaded_to_this_item' => 'Uploaded to this Gruppe',
        'items_list'            => 'Gruppe list',
        'items_list_navigation' => 'Gruppen list navigation',
        'filter_items_list'     => 'Filter Gruppen list'
    $args = array(
        'rewrite'               => array( 'slug' => 'gruppen' ),
        'label'                 => 'Gruppe Post Type',
        'description'           => 'Gruppe erfassen',
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'excerpt' ),
        'hierarchical'          => true,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 6,
        'menu_icon'             => 'dashicons-groups',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
    register_post_type( 'gruppen', $args );
add_action( 'init', 'gruppen_post_type' );

this is the content of 'page-gruppen.php':

<?php get_header(); /* Template Post Type: Gruppen, Gruppen */ ?>
    <div id="sidebar">
        <?php get_sidebar(); ?>
    <div id="main">
        <div class="gruppen-album-holder">
            <?php if (have_posts() && the_excerpt() == 'Blauring') : while (have_posts()) : the_post(); ?>
            <div id="<?php the_title(); ?>" class="gruppen-album"><img src="" alt="<?php the_title(); ?>">
                <h4><?php the_title(); ?></h4>
                <p><?php the_content(); ?></p>
            <?php endwhile; endif; ?>
<?php get_footer(); ?>

1 Answer 1


It should be single-gruppen.php, not page-gruppen.php. Try renaming your file.

This is the explanation of why that works from the template hierarchy: https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post

  • i change this to single-gruppen.php but it uses the index.php template. Nov 19, 2021 at 19:01
  • Are single-gruppen.php and index.php in the same folder (root of the theme)? Also you could try re-saving permalinks in Settings > Permalinks to see if that helps.
    – Michelle
    Nov 19, 2021 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.