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.

By using a plugin called "Custom Content Type Manager", I have implemented in my blog a simple Custom Post Type called "game review" which is simple a post, plus some extra fields which represents the rating of the game for graphics, sound, etc...

However, I could not find a plugin which helps in rendering/displaying this custom type. I understand, that I can create a page called single-game-review.php and this will be used to render it, but I found this not very convenient. The problem is that whenever I change theme, I have to recreate the file. Also the logic of the theme is duplicated in the new file.

An idea would be to redefine the function the_content() so that when it's used on "game review" post, the output is actually the content of the post itself plus the extra fields rendered for example as unordered lists. In this way I can change these without breaking the rendering of the custom post type.

There are plugins which can do that? Or I have to do it by hand in a completely unsupported way that breaks ad the first update?

share|improve this question
    
I don't think the smartest way to implement this is by using plugins. I personally believe it would be better to define your post types by adding a post-type.php file and "render" it with a movies.php file, then add it to a child theme so changes and updates to the main theme won't break it. But you could look at this plugin wordpress.org/extend/plugins/custom-post-type-ui . This plugin does exactly what you want and need, you do however have to recreate your game review post type. –  Aleks Jul 3 '12 at 8:35
1  
That would be bad practice, as the content would be tied to the theme. Always separate out the data from the theme so it's portable. –  Tom J Nowell Jul 3 '12 at 9:16
    
Show/Link your template code. –  kaiser Jul 3 '12 at 12:42
add comment

2 Answers 2

up vote 2 down vote accepted

+1 to putting your post types in a dedicated plugin

What you'll want is to do something like what BBPress and Buddypress are doing.

In BBPress, default templates are provided. If the theme provides none, the defaults are used. All the themer has to do is add

add_theme_support( 'bbpress' );
share|improve this answer
add comment

Yes, anything a user would expect to keep after changing themes belongs in a plugin. This includes custom post types, taxonomies, metaboxes, and shortcodes.

Very useful info at:

  • Core Functionality Plugin

    As described in more detail by others (Otto, WPCandy…), a WordPress theme should only contain that which relates to the look and feel of the site. Any core functionality belongs in a plugin.

and

  • Creating a custom functions plugin for end users

    Most of the WordPress tutorials I write mention adding custom functions to your theme’s functions.php file. Many of the other tutorials around the Web will use this same technique for adding custom code. However, there are different ways of handling custom functions.

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.