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>
<div id="main">
<h3>Titel</h3>
<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>
</div>
<?php endwhile; endif; ?>
</div>
</div>
<?php get_footer(); ?>