Displaying Custom Post Type Archive
Learn to create an archive page for a custom post type.
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 ...