2025-03-26 02:54:59
Custom Post Type is a feature that helps you manage and display different types of content separately, such as portfolios, reviews, or products, making your website more organized and allowing visitors to find information more easily.
However, creating an Archive page for a Custom Post Type can be complex for beginners. In this article, we will teach you how to create an Archive page for a Custom Post Type in WordPress in a detailed and easy-to-understand manner.
Normally, WordPress already has two standard post types: "Posts" and "Pages." Some plugins, such as WooCommerce, add their own Custom Post Types, like "Products."
When you create a Custom Post Type, WordPress will automatically generate an Archive page for it, which is a page that collects all posts of that Custom Post Type. However, the theme you are using may not have a template for the Custom Post Type and might use the default template instead.
If you want to customize the display of the Archive page, you can create your own template. We will guide you on how to do this in the following section.
Before creating an Archive page, make sure that your Custom Post Type supports the Archive function. You can easily check this, for example, if you have a Custom Post Type named "movies" and have enabled SEO-friendly permalinks, the URL of the Archive page should be:
https://example.com/movies
If you encounter a 404 page, it means that the Archive function for your Custom Post Type is not enabled.
If you create a Custom Post Type using a plugin like "Custom Post Type UI (CPT UI)," go to the plugin settings and enable the "Has Archive" option.
If you create a Custom Post Type with code, modify the register_post_type function by adding 'has_archive' => true: จริง:
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'movies',
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
'public' => true,
'has_archive' => true,
)
);
}
Save the changes and try loading the Archive page again.
If you want the Archive page of a Custom Post Type to look different from the general Archive page of the website, you can create your own template file.
Another easier method is to use the SeedProd plugin, which is a drag-and-drop page builder that doesn't require coding.
Creating and customizing Archive pages for Custom Post Types in WordPress helps keep your website organized and makes it easier for users to find information. You can either edit the code directly or use plugins like SeedProd to conveniently design Archive pages.
2025-01-10 10:12:01
2024-05-31 03:06:49
2024-05-28 03:09:25
There are many other interesting articles, try selecting them from below.
2025-03-13 11:08:24
2023-11-16 09:12:38
2023-11-15 10:19:13
2025-03-05 10:17:38
2024-08-26 10:06:54
2023-11-06 01:29:10
2024-09-25 04:56:27