Page attribute template dropdown not displayed even the syntax is correct

If you’re wanting to enable the Page Template dropdown for a custom post type, you have to enable support for “page attributes” when you define your CPT.

You should currently have something like

register_post_type('foo',
    array('labels' => array(
        ...
    ),
);

You need to add ‘supports’:

register_post_type('foo',
    array('labels' => array(
        ...
    ),
    'supports' => array('title', 'editor', 'page-attributes'),
);

‘page-attributes’ will allow your CPT to use Page Templates, which is what enables the dropdown menu. ‘title’, ‘editor’, etc. etc. are optional depending on your needs.

Since your CPT is already defined, you will probably need to first call unregister_post_type() to “unregister” it and then re-register it with your new code.

Leave a Comment