Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I first heard about custom post types I thought it would solve an old "problem" I have, so I was thrilled.
But when I tried to setup something I couldn't achieve what I want.
So I'd like to know if I'm using WP tools correctly, or if there is a plugin (or a combination of plugins) that would do what I want.

Context :
On my blog I have several categories that contains "copy pasted posts", which are posts that have a static structure and where only a few information change (a category = a specific post "format"). So to create it, I copy/paste an old one and replace a few things (some urls, titles...). There are a dozen of these.
I use a site template found on WP.com, but heavily modified and single.php has a lot of content that I don't want to copy/paste to other files.

Problem :
I tried to use a plugin to manage custom post types. The idea was to define a post type for each category. I think this is the intended use, but my problem is that I don't want to duplicate the single.php because any modification of my template would imply that I have to edit a dozen of files and all of my "custom types" are all almost the same as "normal" posts, it's only their content that is fixed. And it also implies to edit other files : search results, listings...
Moreover I see some possible issues here : as the post titles are not defined and are dependant on the custom fields content, I'm afraid that the search may not work on them (I didn't try it though).
Moreover I prefer to be able to define the post content template as "WP admin" (through UI) instead of "WP developer" (through file editing & FTP).

What I would ideally want :
So I imagined another solution, but I don't know how feasible it is :
I'd like the mix of two plugins : "Ultimate Post Type Manager" and "Simple post template" (this plugin allows to define a default post content. It adds a button on the "new post" page which, when clicked, fills the post body with a predefined content).

I'd like, when I create a custom post type to define a default post body (and title). (as it is possible with "Simple post template" but this plugin only allows the creation of one global post template only).
As we can define custom fields, I'd like to be able to put fields replacement tokens in that content template.
The result would be that when I click on "Add new [my type]" for my custom post type, I don't see a title or body field, but only my custom fields.
When I click on publish, it would fill the title and body with the content defined with the tokens replaced by the value entered in the fields and save it to the database.

In short, it would create the post layout from some data entered in a form before writing it in the database while the common use is to set the layout at "display time", a kind of "creation-side" template (versus a "display-side").

I know this is quite agains the "less display instructions in DB, more in template", but I prefer this way in my situation.

I'm I thinking it in a wrong way (You have the right to say that it is a total nonsense !) ? Is there already something that would allow me do to that ?
What would be my best solution to get something similar ?
After some thinking, I'm not sure using custom post types is a good idea here...

Updated :
Rephrased, edited layout, added details & links.

share|improve this question
    
I find it difficult to understand what your asking for, maybe you can summarize or rewrite it to be more clear, specifically why you don't want to use a custom template for a custom post type. –  Wyck Dec 6 '10 at 15:14
    
Ok sorry, I'll rephrase it... I don't want a custom template mostly because I don't want to copy / paste single.php and because I want the post's body to be defined "as is", easily exportable from the DB (as text,...), not depending on the template. –  Julien N Dec 6 '10 at 15:51
3  
What if you created templates for each post content only, and included that in your single.php (and other theme files) where you normally put the_content()? get_template_part( 'content', $post->post_type ) is very handy here. –  Jan Fabry Dec 6 '10 at 16:45
add comment

1 Answer 1

As already somehow suggested in the comments, I think the most easy thing is to get a solution to your "I don't want to duplicate template files all over the place because they contain all the same" by modularizing those.

E.g. by using template parts - and I think that's even more powerful - by hooking into the template loader (see template-loader.php). See as well Template Actions (Wordpress Codex) and the Wordpress 3.0 Program Flow (Toolpress PDF).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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