0

I'm having some trouble understanding the logic, I'll try to explain.

Let's say I want to have a Video section. This is how I (want to) do it.

  • I make a custom post type called "Videos";
  • I make a template to show the video items, call it tpl-videos.php;
  • I make a normal page called "Videos", and select the tpl-videos.php as my page template;

Ofcourse, this works, UNLESS you are using some kind of pagination, let's say PagNavi. Whenever I go to page 2, I get an error 404. Reason being: my CPT has the same name as my page.

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 "Video-items" as CPT, and "Videos" as page. But that's not what I want for my URL's: That will make site.com/videos/video-items/my-video-item, but I want site.com/videos/my-video-item.

The correct way is making an archive-videos.php. But, with an archive page I cannot take advantage of the normale page stuff, like Metaboxes, Thumbnails etc etc.

Is there a way to make archive pages behave as pages, without making custom options for each archive page?

Edit: There was a misunderstanding regarding my use of Blog as a CPT. Blog can be anything: videos, galleries, whatever. Question updated.

2
  • Can you not just call it something else? 'blog-entry' perhaps. Also it seems a bit odd to have 'blog' as a custom post type when you have all the functionality you would need with 'posts'.
    – mantis
    Nov 13 '13 at 12:39
  • I use the posts cpt for News. Blog is another section.
    – Don Munter
    Nov 13 '13 at 13:17
2

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.

3
  • I may have mistyped some things. I know I can use thumbnails and metaboxes for the posts inside the Blog CPT, I actually meant the Blog page itself (the page wich displays all the blogitems). This is the archive-page, but I can't use the page functionality on them.
    – Don Munter
    Nov 13 '13 at 13:20
  • What specific page (i.e. static page) functionality do you need/want to use on your CPT archive index page? Nov 13 '13 at 13:33
  • Well, everything the normal pages also have. For example, I have a quotes metabox, a header slider metabox wich I want to use on all available pages. (I don't want to make seperate options pages for each archive). I think it's not gonna work though.. CPT's cannot have the same name as a page if you wanna use the %postname% permalink setting, am I right?
    – Don Munter
    Nov 13 '13 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.