How Do I Create an Archive Post Type Template in WordPress?
Creating an archive post type template in WordPress is simple. Just follow these steps:
1. Click on the “Admin” menu item and then select “Themes”.
2. Locate the theme you want to use for your archive post type and click on it.
3. On the theme’s “Design” screen, look for the “post types” section and click on it.
4. On the “post types” screen, locate the “archive” post type and click on it.
5. On the “archive” post type’s “Template” screen, click on the “Add new” button.
6. On the “Add new” screen, enter the following information:
Name: Archive
Description: A WordPress archive post type for posts that are older than a certain number of days.
7. Click on the “Create” button and your new archive post type template is ready to use.
Now that you have created your archive post type template, you need to add some code to your theme’s functions.php file to enable it. To do this, open the file in your text editor of choice and enter the following:
/**
The WordPress archive post type.
*/
function archive_post_type() {
return array(
‘name’ => ‘archive’,
‘description’ => __( ‘A WordPress archive post type for posts that are older than a certain number of days.’, ‘wp-admin’ ),
‘deactivated’ => true,
‘post_type_name’ => ‘archive’,
‘taxonomy’ => ‘post_type’,
‘public’ => true,
‘ show_in_nav_menu’ => true,
‘show_in_search_result’ => true,
‘show_in_admin_bar’ => true,
‘supports’ => array(
‘title’ => true,
‘theme_location’ => true,
‘the_permalink’ => true,
‘translations’ => true,
‘type’ => ‘post_type’,
‘language’ => ‘en’,
‘meta_title’ => ‘Post Type Title’,
‘rewrite_exists’ => false,
‘public_post_status’ => ‘publish’,
),
‘default_taxonomy’ => ‘post_type’,
}
add_action( ‘init’, ‘archive_post_type’);
add_action( ‘delete_post’, ‘archive_post_type’);.