0

I'd like to pre-define page_template choice in the page attributes when creating a new post in a custom post type.

Found lots to do with adding parents defaults, but stuck getting past that.

3 Answers 3

3

You need to create the template files within your theme using the correct naming.

Please see:

https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-page-templates-for-specific-post-types

2
  • 1
    I guess I wasn't clear - I want the template auto selected when I add a new post / page / custom post type. So under page attributes, my client doesn't have to keep selecting page template and selecting the custom template from the drop down box. Commented Jul 17, 2017 at 12:37
  • 1
    Please take a look at: wordpress.stackexchange.com/questions/204657/…
    – lky
    Commented Jul 17, 2017 at 12:48
1

It's in the filename. single-$posttype.php, archive-$posttype.php

2
  • 1
    maybe I wasn't too clear - I want the custom template, using the newer method of template identification that heady12 references above, auto selected when I click new page (or new custom post type) Commented Jul 17, 2017 at 12:36
  • How many different templates do you need per post type (foo)? If it's one, call it single-foo.php, if it's more than one call the default single-foo.php and use the Template Post Type header in the others.
    – Chris Cox
    Commented Jul 17, 2017 at 13:01
0

As heady12 pointed out

Apply template to custom post type

With some modifications to conditions this worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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