The WordPress Template Hierarchy for custom post type archive index pages provides the solution.
Simply create a template file, named archive-{post-type}.php
– which in your case would be archive-blog.php
. WordPress will create the archive index automatically (provided you set 'has_archive' => true
in your register_post_type()
call), will use the archive-blog.php
automatically, and pagination will work out of the box.
The correct way is making an archive-blog.php. But, with those pages I cannot take advantage of the normale page stuff, like Metaboxes, Thumbnails etc etc.
Why not? For Featured Images, simply enable support for post-thumbnails for your CPT, in your register_post_type()
call. For metaboxes: what metaboxes do you want to use for your CPT? For a custom post meta box, that’s as easy as adding an add_meta_box()
call, and changing $posttype
to blog
.
So I have to change one of them, wich I don’t want, ’cause that’s weird. If I do that, it will most likely be “Blog-items” as CPT, and “Blog” as page. But that’s not what I want for my URL’s.
And if all you’re trying to do is use an /blog
endpoint for your blog posts index, just use a Static Front Page, create a static page named “Blog”, and then assign it as the page for posts via Settings -> Reading
. No custom post type required.