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 url: site.com/movie/terminator-2/ 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.
Edit: Tried solution: I've added a rewrite rule
global $wp,$wp_rewrite; $wp->add_query_var('movieslug'); $wp_rewrite->add_rule('(.*)movie/([^/]+)', 'index.php?pagename=movie-template&movieslug=$matches', 'top');
This seems to work and i used filter the_title to change the title, but this doesn't change the
<title> tag, and this doesnt really feel like a solution, any ideas would be welcome.