因为在我所有尝试获取自定义帖子类型存档的过程中,我只得到了一个404
尝试在存档中组织不同的帖子类型。php
我正在努力做到这一点archive.php
<?php
/*===== Start Conditionals for Categories =====*/
$post = $wp_query->post;
$post_type = get_post_type($post);
if($post_type == \'mysuper_post_type\') {
load_template( trailingslashit( get_template_directory() ) . \'layouts/archive-super_posttype.php\' );
} else {
load_template( trailingslashit( get_template_directory() ) . \'layouts/category-default.php\' );
}
}
/*===== End Conditionals for Categories =====*/
?>
这是注册我的CPT的代码// BrandVoice
function brand_voice() {
$section = \'brand_voice\';
$slug = \'brand-voice\';
$names = \'Brands Voice\';
$name = \'Brand Voice\';
$desc = \'Adding Brand Voice\';
$key = $section;
$taxonomy = \'brand\';
$slug{$taxonomy} = $taxonomy;
$names{$taxonomy} = \'Brands\';
$name{$taxonomy} = \'Brand\';
$labels = array(
\'name\' => _x( $name, $desc, $section),
\'singular_name\' => _x( $name, $desc, $section),
\'menu_name\' => __( $names, $section ),
\'parent_item_colon\' => __( \'Parent \'.$name.\':\', $section ),
\'all_items\' => __( \'All \'.$names.\'\', $section ),
\'view_item\' => __( \'View \'.$names.\'\', $section ),
\'add_new_item\' => __( \'Add New \'.$name.\'\', $section ),
\'add_new\' => __( \'Add New \'.$name.\'\', $section ),
\'edit_item\' => __( \'Edit \'.$name.\'\', $section ),
\'update_item\' => __( \'Update \'.$name.\'\', $section ),
\'search_items\' => __( \'Search \'.$names.\'\', $section ),
\'not_found\' => __( \'Not found\', $section ),
\'not_found_in_trash\' => __( \'Not found in Trash\', $section ),
);
$rewrite = array(
\'slug\' => $slug,
\'with_front\' => true,
\'pages\' => true,
\'feeds\' => true,
);
$supports = array(
\'title\',
\'editor\',
\'excerpt\',
\'author\',
\'thumbnail\',
\'comments\',
\'revisions\',
\'post_formats\',
);
$taxonomies = array(
\'category\',
\'post_tag\',
);
$args = array(
\'label\' => __( $key, $section ),
\'description\' => __( $desc, $section ),
\'menu_icon\' => \'dashicons-\'.$slug.\'\',
\'labels\' => $labels,
\'supports\' => $supports,
\'taxonomies\' => $taxonomies,
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'query_var\' => $key,
\'rewrite\' => $rewrite,
\'capability_type\' => \'page\'
);
register_post_type( $key, $args );
}