Do you want to create a custom post type archive page in WordPress?
Typically, custom post types in WordPress will use the theme's archive template. You can also create your own custom archive page for your post type.
In this article, we will show you how to easily create custom post type archive pages in WordPress.
What is a custom post type archive page in WordPress?
The Custom Post Type Archive page is where users can view all items archived under a specific custom post type.
When you create a custom post type, WordPress automatically generates an archive page for that post type. An archive page is a list of all posts associated with that custom post type. This allows visitors to easily browse and access content in that particular post type.
By default, WordPress comes with two commonly used post types, called Posts and Pages. The WordPress plugin can also create its own post types.
For example, WooCommerce adds a new post type called "Product" to your WordPress site.
Similarly, you can create custom post types and use them to manage different types of content.
After you create a custom post type, you can use it within the WordPress admin area. However, your WordPress theme is responsible for displaying all your content.
If your theme does not have a template for a specific post type, WordPress will use the default archive template to display any post type archive page.
To learn more, see a guide on WordPress template hierarchy and how to use them in WordPress themes.
Now, if you want to change how the custom post type archive page appears, you can do it by creating a custom template.
That being said, let's see how to easily create custom post type archive pages in WordPress.
Enable archive for your custom post type in WordPress
Before creating and using a custom post type archive page, first make sure that your custom post type has archive enabled.
For example, if your custom post type is called a movie and you have SEO-friendly permalink enabled, your post type archive will be marked as:
Now, if you use a plugin to generate a custom post type, you can simply edit it there and enable the archive feature.
For example, in the CPT UI plug-in, you can edit custom post types and turn on the "Available" feature under Post Type settings.
On the other hand, if you use code to generate a custom post type, you need to edit that code to enable archives.
Here is a short example of the code that generates the post type. You can see that the last line has an additional property to enable the archive page:
From here, you need to download the archive.php file to your computer.
After downloading, you need to rename the file to archive-{posttype}.php, where {posttype} is the name of your custom post type.
For example, if your custom post type is called a movie, then you need to rename it to archive-movie.php.
You can now open this file with any plain text editor (such as Notepad) for any changes.
This file already contains all the code needed to display the content of a custom post type. You can add any code you want to add or change the layout of an existing template.
Tip: If you need help, see our WordPress theme development cheat sheet for beginners.
Once you are satisfied with the changes, don't forget to save the file.
After that, you need to upload this file to your WordPress theme folder using the FTP or File Manager application.
You can now access the Custom Post Type Archive page to see the actual changes.
Use SeedProd to create custom post type archive pages
For this method, we will use SeedProd. It is the best WordPress page builder plugin on the market, making it easy for you to create custom pages for your website.
It comes with a drag and drop interface, allowing you to easily design custom post type pages without writing any code. You can also use SeedProd to design other pages on your website and even create custom themes from scratch.
First, you need to install and activate the SeedProd plugin. For more details, see our step-by-step guide on how to install WordPress plug-ins.
After activation, you need to enter the SeedProd license key. You can find this information in your account on the SeedProd website.
Next, you need to go to SeedProd » Landing Pages .
From here, click the "Add New Landing Page" button to start.
Next, you need to select a template for your page.
If there is a template similar to your website design, then you can use that template or start with a blank template.
Next, you need to provide the page name and select the URL.
Make sure you use content that represents your custom post type.
This will take you to the page builder interface.
You can select a layout to start and start adding blocks from the left column.
We first add post blocks to display items in the custom post type.
Simply drag and drop the Posts block in the Advanced section onto your page.
By default, the post block will display your blog post.
Click Block Settings and select your post type from the Query by Post Type section.
After that, you can view additional options to open featured images, change excerpt size, and more.
Once you have finished setting up your post block, you can switch to the Sections tab and add a header or footer to the page layout.
After you have finished editing, you can continue publishing the page.
Just click the drop-down arrow next to the Save button and select Publish.
You can now access the custom page by clicking the Preview tab to see how it works.
Here is what our custom post type archive page looks like on our test site.
You can also add this page to the navigation menu or continue editing to optimize it further.
Example of custom post type archive page
Custom templates for archive pages using post type allow you to customize them to suit your needs.
For example, you can delete the sidebar, change the page layout, and provide more context to make the archived page more attractive.
Here are some examples of custom post type archive pages with their own custom templates.
The WPBeginner transaction page is a custom post type that uses its own archive template.
We also use custom templates for the WordPress glossary section.
This is also a custom post type.
Our friends at MemberPress use custom post type archive templates in their plugin section.
You can see the example in the screenshot below.
We hope this article helps you understand how to easily create custom post type archive pages. You may also want to check out our list of essential WordPress plugins and tools for our business website, or our expert comparison of the best commercial VoIP providers.
The above is the detailed content of How to Create a Custom Post Type Archive Page in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Enable comments on your WordPress website to provide visitors with a platform to participate in discussions and share feedback. To do this, follow these steps: Enable Comments: In the dashboard, navigate to Settings > Discussions, and select the Allow Comments check box. Create a comment form: In the editor, click Add Block and search for the Comments block to add it to the content. Custom Comment Form: Customize comment blocks by setting titles, labels, placeholders, and button text. Save changes: Click Update to save the comment box and add it to the page or article.

How to copy WordPress subsites? Steps: Create a sub-site in the main site. Cloning the sub-site in the main site. Import the clone into the target location. Update the domain name (optional). Separate plugins and themes.

The steps to create a custom header in WordPress are as follows: Edit the theme file "header.php". Add your website name and description. Create a navigation menu. Add a search bar. Save changes and view your custom header.

Enable comments in WordPress website: 1. Log in to the admin panel, go to "Settings" - "Discussions", and check "Allow comments"; 2. Select a location to display comments; 3. Customize comments; 4. Manage comments, approve, reject or delete; 5. Use <?php comments_template(); ?> tags to display comments; 6. Enable nested comments; 7. Adjust comment shape; 8. Use plugins and verification codes to prevent spam comments; 9. Encourage users to use Gravatar avatar; 10. Create comments to refer to

You can install the FTP plug-in through WordPress, configure the FTP connection, and then upload the source code using the file manager. The steps include: installing the FTP plug-in, configuring the connection, browsing the upload location, uploading files, and checking that the upload is successful.

How to copy WordPress code? Copy from the admin interface: Log in to the WordPress website, navigate to the destination, select the code and press Ctrl C (Windows)/Command C (Mac) to copy the code. Copy from a file: Connect to the server using SSH or FTP, navigate to the theme or plug-in file, select the code and press Ctrl C (Windows)/Command C (Mac) to copy the code.

WordPress Error Resolution Guide: 500 Internal Server Error: Disable the plug-in or check the server error log. 404 Page not found: Check permalink and make sure the page link is correct. White Screen of Death: Increase the server PHP memory limit. Database connection error: Check the database server status and WordPress configuration. Other tips: enable debug mode, check error logs, and seek support. Prevent errors: regularly update WordPress, install only necessary plugins, regularly back up your website, and optimize website performance.

How to turn off a comment in WordPress? Specific article or page: Uncheck Allow comments under Discussion in the editor. Whole website: Uncheck "Allow comments" in "Settings" -> "Discussion". Using plug-ins: Install plug-ins such as Disable Comments to disable comments. Edit the topic file: Remove the comment form by editing the comments.php file. Custom code: Use the add_filter() function to disable comments.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.