Displaying Custom Post Type Archive
Explore how to display custom post type archives in WordPress by creating an archive template, customizing the query to sort posts alphabetically, and updating navigation to improve site structure. This lesson helps you understand how to manage and present your custom content effectively.
While creating the course post type, we set the has_archive property to true. This enables the archive page for the custom post type.
For a custom post type, WordPress will check for a template file named archive-$post-type.php. If it is not found, it will use archive.php to display the archive page.
We can find the course archive at school-of-excellence.local/courses/. Alternatively, by clicking on the All Courses link from a single course post (e.g., school-of-excellence.local/courses/organic-chemistry/), we are taken to the archive page for the course post type. On inspection, we can see that the template file powering this page is ...