Use a page as a template for a custom post type

I’m trying to develop a plugin with a custom post type that can be used in different themes thats why creating a single-post_type.php template file is out of the question. The custom post type has a lot of meta fields that i want to place by using placeholders.

At the moment the plugin looks for a default page.php template in de current theme. But often templates have extra settings to design the page that i cant use because every theme works in different ways.

My idea is to use an existing (non published) page as template for my custom post type. By adding shortcodes (placeholders) to the page that get replaced by the content of the custom post type. How would i make this possible.


post:       Template
post type:  page
url:        --not published--
content:    <h1>[placeholder field="title"]</h1>
            <p>Genre: [placeholder field="genre"]</p>

post:       Terminator 2
post type:  movie
meta genre: action
meta actor: Arnold
content:    <h1>Terminator 2</h1>
            <p>Genre: action</p>

I know how to use the placeholders but how could i use the template page as template so that i could use all the functionalities of the used theme.

Read more here: Use a page as a template for a custom post type

Leave a Reply

Your email address will not be published. Required fields are marked *