したがって、それぞれに同じ投稿名を持つカスタム投稿タイプがいくつかあります。
Post Type: Service (http://www.example.com/service/skincare)
Post Type: Price (http://www.example.com/price/skincare-2)
Post Type: FAQ (http://www.example.com/faq/skincare-3)
URL を書き換えて番号を削除したいので、次のようになります。
Post Type: Service (http://www.example.com/service/skincare)
Post Type: Price (http://www.example.com/price/skincare)
Post Type: FAQ (http://www.example.com/faq/skincare)
誰も私がこれを行う方法を知っていますか?
ここにすべての私のカスタム郵便番号があります:
/*
* ========================================================================
* Custom Post Types
* ========================================================================
*/
// Create 1 Custom Post type for a Demo, called HTML5-Blank
add_action('init', 'create_post_type_html5'); // Add our HTML5 Blank Custom Post Type
function create_post_type_html5()
{
register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
register_taxonomy_for_object_type('post_tag', 'html5-blank');
register_post_type('html5-blank', // Register Custom Post Type
array(
'labels' => array(
'name' => __('Services', 'html5blank'), // Rename these to suit
'singular_name' => __('Services', 'html5blank'),
'add_new' => __('Add New', 'html5blank'),
'add_new_item' => __('Add New Services', 'html5blank'),
'edit' => __('Edit', 'html5blank'),
'edit_item' => __('Edit Services', 'html5blank'),
'new_item' => __('New Services', 'html5blank'),
'view' => __('View Services', 'html5blank'),
'view_item' => __('View Services', 'html5blank'),
'search_items' => __('Search Services', 'html5blank'),
'not_found' => __('No Servicess found', 'html5blank'),
'not_found_in_trash' => __('No Service\'s found in Trash', 'html5blank')
),
'rewrite' => array('slug' => 'service','with_front' => false),
'public' => true,
'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
), // Go to Dashboard Custom HTML5 Blank post for supports
'can_export' => true, // Allows export in Tools > Export
'taxonomies' => array(
'post_tag',
'category'
) // Add Category and Post Tags support
));
}
add_action('init', 'create_post_type_html5_2'); // Add our HTML5 Blank Custom Post Type
function create_post_type_html5_2()
{
register_taxonomy_for_object_type('category', 'html5-blank2'); // Register Taxonomies for Category
register_taxonomy_for_object_type('post_tag', 'html5-blank2');
register_post_type('html5-blank2', // Register Custom Post Type
array(
'labels' => array(
'name' => __('Prices', 'html5blank2'), // Rename these to suit
'singular_name' => __('Prices', 'html5blank2'),
'add_new' => __('Add New', 'html5blank2'),
'add_new_item' => __('Add New Prices', 'html5blank2'),
'edit' => __('Edit', 'html5blank2'),
'edit_item' => __('Edit Prices', 'html5blank2'),
'new_item' => __('New Prices', 'html5blank2'),
'view' => __('View Prices', 'html5blank2'),
'view_item' => __('View Prices', 'html5blank2'),
'search_items' => __('Search Prices', 'html5blank2'),
'not_found' => __('No Prices found', 'html5blank2'),
'not_found_in_trash' => __('No Price\'s found in Trash', 'html5blank2')
),
'rewrite' => array('slug' => 'prices','with_front' => false),
'public' => true,
'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
), // Go to Dashboard Custom HTML5 Blank post for supports
'can_export' => true, // Allows export in Tools > Export
'taxonomies' => array(
'post_tag',
'category'
) // Add Category and Post Tags support
));
}
add_action('init', 'create_post_type_html5_3'); // Add our HTML5 Blank Custom Post Type
function create_post_type_html5_3()
{
register_taxonomy_for_object_type('category', 'html5-blank3'); // Register Taxonomies for Category
register_taxonomy_for_object_type('post_tag', 'html5-blank3');
register_post_type('html5-blank3', // Register Custom Post Type
array(
'labels' => array(
'name' => __('FAQ', 'html5blank3'), // Rename these to suit
'singular_name' => __('FAQ', 'html5blank3'),
'add_new' => __('Add New', 'html5blank3'),
'add_new_item' => __('Add New FAQ', 'html5blank3'),
'edit' => __('Edit', 'html5blank3'),
'edit_item' => __('Edit FAQ', 'html5blank3'),
'new_item' => __('New FAQ', 'html5blank3'),
'view' => __('View FAQ', 'html5blank3'),
'view_item' => __('View FAQ', 'html5blank3'),
'search_items' => __('Search FAQ', 'html5blank3'),
'not_found' => __('No Prices found', 'html5blank3'),
'not_found_in_trash' => __('No FAQ\'s found in Trash', 'html5blank3')
),
'rewrite' => array('slug' => 'faq','with_front' => false),
'public' => true,
'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
), // Go to Dashboard Custom HTML5 Blank post for supports
'can_export' => true, // Allows export in Tools > Export
'taxonomies' => array(
'post_tag',
'category'
) // Add Category and Post Tags support
));
}
add_action('init', 'create_post_type_html5_4'); // Add our HTML5 Blank Custom Post Type
function create_post_type_html5_4()
{
register_taxonomy_for_object_type('category', 'html5-blank4'); // Register Taxonomies for Category
register_taxonomy_for_object_type('post_tag', 'html5-blank4');
register_post_type('html5-blank4', // Register Custom Post Type
array(
'labels' => array(
'name' => __('Before and After', 'html5blank4'), // Rename these to suit
'singular_name' => __('Before and After', 'html5blank4'),
'add_new' => __('Add New', 'html5blank4'),
'add_new_item' => __('Add New Before and After', 'html5blank4'),
'edit' => __('Edit', 'html5blank4'),
'edit_item' => __('Edit Before and After', 'html5blank4'),
'new_item' => __('New Before and After', 'html5blank4'),
'view' => __('View Before and After', 'html5blank4'),
'view_item' => __('View Before and After', 'html5blank4'),
'search_items' => __('Search Before and After', 'html5blank4'),
'not_found' => __('No Before and After found', 'html5blank4'),
'not_found_in_trash' => __('No Before and After\'s found in Trash', 'html5blank4')
),
'rewrite' => array('slug' => 'before-and-after','with_front' => false),
'public' => true,
'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
), // Go to Dashboard Custom HTML5 Blank post for supports
'can_export' => true, // Allows export in Tools > Export
'taxonomies' => array(
'post_tag',
'category'
) // Add Category and Post Tags support
));
}