Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've successfully added a custom post type.

register_post_type('case',
        array(
            'labels' => array(
                'name' => __('Cases'),
                'singular_name' => __('Case')
            ),
            'public' => true,
            'has_archive' => true,
            'supports' => array('title', 'editor', 'thumbnail','custom-fields', 'page-attributes')
        )

    );

And I've created a page called "case" and I have my permalinks configured like this:

/%postname%

The problem I'm having now is that when I try to access url.com/case I don't get my page "case" but instead I'm looking at the custom post type "case". I think?

Every "case" has its own url --> url.com/case/xxx. I don't want to change this but instead be able to change the layout for the custom page "main" page that represents all the cases instead of a "page" called case.

Can this be done and how?

share|improve this question

2 Answers 2

I got it by searching some more on google.

'has_archive' => true,

This line is vital.

Found out I had to rename my custom template pages to archive-"the custom type name" which in this case was.

archive-case.php

Because of this I could remove my "static" page called case and let the system pick the right template page for the custom post type.

share|improve this answer

In the arguments ($args) parameter of the register_post_type function, there is a variable named rewrite. By default it is true, try to set it to false.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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