Rendering Custom Post Types independently of the theme in use

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.

Read More

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?

Related posts

Leave a Reply

2 comments

  1. +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' );
    
  2. 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.