I have created a custom post type and have shown it using a custom template.

I created a page, gave it a custom template, Template Name: my custom project post type

I want to only show 1 post on this page and at the bottom have a next post and previous post link so that you can move up or down the posts. When I got the previous post link to work, it loaded the next post in in archive.php instead of using my custom post type loop that is in the page template.

I have thought about using just the archive page or whatever default template it would be to display the posts. I thought I could throw in a ( if is my custom post type, display this info )

I am looking for the best most efficient way to do this. Does anyone have any advice as to the best way to accomplish this? My biggest issue is getting the next and previous post link to display the content properly. It's not like a typical blog post. I have special formatting with extra featured images and all that. In my template, I tried using get_next_post_link() but found that it returns NULL. Previous_post_link works but as I said, it loads the post in the archive template.


You're not using templates correctly. You don't use a custom page template to output custom posts or a custom post archive. There are dedicated templates you need to create to give your post type its own templates. Refer to the Template Hierarchy.

For example, if your post type is called event, you need to create archive-event.php as the template for the list of events that will appear automatically at /event (or /events, whatever slug you set when registering). Then you need to create single-event.php as the template for the single view of your post type. You shouldn't be using pages to output archives or custom post types.

  • I tried your solution and got nothing. I am not saying it's wrong, just saying that it isn't working. My custom post type was registered as mosty_projects. So I created an archive-mosty_projects.php and then flushed the permalinks and nothing shows. my capability type is post. I will keep trying. I know this should work. The other issue with this solution is that it doesn't allow a person to customize the page with a page builder. – Jamie Sep 22 '17 at 3:03
  • How are you registering the post type? – Jacob Peattie Sep 22 '17 at 3:17
  • You may have registered the CPT without has_archive set to true. If so, you need to unregister it and re-register with that flag true. – WebElaine Sep 22 '17 at 14:56
  • I have the capability type set to post and the has_archive was set to true and I am registering it with register_post_type('mosty_projects", $args); – Jamie Sep 23 '17 at 1:31

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.