4

I have created a custom post type in wordpress and have 90% of the functionality working correctly, but I am having a bit of trouble trying to create a custom listing page template.

Currently it is using the default index.php page to bring out all the posts and I have tried to override this by creating a page-post-type.php page but didn't seem to work.

What would be the best method for creating a custom post type listing page?

Cheers, Jamie.

5

I think you want to create archive page for custom post type, create archive-{post_type}.php and it'll display you custom post type content.

Also see codex: http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display

  • 2
    Note that if you've named your custom post type post-typename instead of post_typename, it won't work. The hyphen (-) in template names separates the properties that map to the template file, and custom type names that include a hyphen break the mapping. – marfarma Aug 4 '11 at 17:56
  • Why should want to create a archive-{post_type}.php page. When we make ` 'has_archive' => true,` when registrring custom post type you can access it like domain.com/custom_post_type (depend on the permalink structure). Am I wrong? – Ranuka Nov 7 '16 at 8:07

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.