我创建了一个自定义帖子类型“gruppen”和一个自定义页面模板“page gruppen”。php’。我想用“page gruppen”。php“显示我的自定义帖子类型内容,但自定义帖子类型始终使用普通wp模板”页面。php\'
当我打印slug时,它会给出最后一个帖子名,而不是gruppen。
我的失败是什么?
这是我的帖子类型:
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\' );
这是“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(); ?>