Displaying Custom Post Type Archive

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 archive.php as the courses are listed in the style of blog posts. Every post has metadata information about the author, date, and category.

Get hands-on with 1400+ tech skills courses.