I realise with this question I was overcomplicating a really simple issue.
My question is really this:
How to have a page listing all items of a given custom post type?
Say the custom post type is foobar, I guess I want to be able to have a URL mydomain.com/foobar which will list them all. No categories involved. And with a template file in PHP which I can entirely customise.
Rather than edit the earlier question I have left it there in case the answers there are useful and applicable should someone need a “page without a page”. But cybmeta is right, in the comments on that question, all I need in my case is an archive page.
Thanks again to cybmeta for his comments in my earlier question.
Of course the solution is to use an archive template. The filename will be archive-foobar.php
. The target URL will indeed be mydomain.com/foobar
.
This works fine, even though for my purposes “archive” is a misnomer. The end user never sees the word “archive”.
Additionally, using the notes here, I needed to remember to:
1) If you want to use a custom archive page for your custom-post-type, add an additional argument to your
register_post_type() arguments: ‘has_archive’ => true…
(This will tell WP to look for an archive template according to the
codex template hierarchy using the current slug setting of your custom
post type. If you want a custom slug for your archives, replace TRUE
with the slug name for example: ‘has_archive’ => ‘products’ might be
the slug you want to use with a ‘product’ post_type.)
2) Visit the Settings -> Permalinks page to flush your current rewrite rules and rebuild with the new rules for your custom archive.