最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

templates - Templating advice sub posts of a CTP

matteradmin10PV0评论

Im looking for advice to generate a few 'default' post templates. Currently this is the setup for the CPT 'projects'.

We generate subpages and select the main post type as parent. This works well to generate the needed hierarchy.

The children of the parent post category will have 5 default templates that are different.

What's the best way to create a 'template' selector for those sub pages?

Thanks a lot.

Im looking for advice to generate a few 'default' post templates. Currently this is the setup for the CPT 'projects'.

We generate subpages and select the main post type as parent. This works well to generate the needed hierarchy.

The children of the parent post category will have 5 default templates that are different.

What's the best way to create a 'template' selector for those sub pages?

Thanks a lot.

Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Oct 18, 2018 at 6:38 DuikbootDuikboot 1312 silver badges6 bronze badges 1
  • sorry, i don't get, what you are looking for, can you please clarify? you want to have a select option inside your cpt to select the template, that will be shown? – honk31 Commented Oct 18, 2018 at 14:28
Add a comment  | 

1 Answer 1

Reset to default 0

For an easy solution, you could just create page templates and set their Template Post Type to match your custom post type. WordPress has supported custom page templates for other post types than page too since version 4.7.

You can read more about it from the Theme handbook // Creating page templates for specific post types

This way you could use the native template selector that you can already see on a page's edit screen on the Page Attributes metabox.

Would this be a viable solution for you?

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far