I am looking for the best way to create custom post-types which are only used as an archive for their posts. As an example I want an archive showing all employees of a company, but I don't want the employees to have a singular page. This is a use-case that I stumbled upon various times, but never found the perfect solution.
The main requirements are:
- disable the singular view of posts;
- be able to use archive.php of the theme as the archive page;
- remove links to the singular view from WordPress.
All methods that I've found are not able to tick all the requirements above.
By setting a filter with a
template_redirect for the single page, the links to the singular pages are still being shown in WordPress (and probably in sitemaps and such), which is confusing for the end-user.
false the links in the back-end are removed, but so is the
archive page, even though
has_archive is set to
true. This can be solved by creating a page with a page template that loads the posts from the post-type. But that's not ideal either.